diff options
Diffstat (limited to 'plugins/org.eclipse.wst.common.frameworks/src')
69 files changed, 0 insertions, 7900 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 4e44b8f50..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java +++ /dev/null @@ -1,181 +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.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.AbstractOperation; -import org.eclipse.core.resources.IWorkspace; -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; - -/** - * Abstract implementation for an IDataModelOperation. - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation - * - * @since 1.0 - */ -public abstract class AbstractDataModelOperation extends AbstractOperation implements IDataModelOperation { - - /** - * Convenience IStatus.OK. - */ - protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS; - - private String id; - private IEnvironment environment; - - /** - * The IDataModel used by this IDataModelOperation - */ - protected IDataModel model; - - /** - * Default constructor. - */ - public AbstractDataModelOperation() { - super(""); //$NON-NLS-1$ - this.id = getClass().getName(); - } - - /** - * Constructor taking an IDataModel - * - * @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(); - } - - /** - * Default implementation of setID(). - * - * @see IDataModelOperation#setID(String) - */ - public void setID(String id) { - this.id = id; - } - - /** - * Default implementation of getID(). - * - * @see IDataModelOperation#getID() - */ - public String getID() { - return id; - } - - /** - * Default implementation of setDataModel() - * - * @see IDataModelOperation#setDataModel(IDataModel) - */ - public void setDataModel(IDataModel model) { - this.model = model; - } - - /** - * Default implementation of getDataModel() - * - * @see IDataModelOperation#getDataModel() - */ - public IDataModel getDataModel() { - return model; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation#getDataModelIDs() - */ - public Set getDataModelIDs() { - return new HashSet(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation#getSchedulingRule() - */ - public ISchedulingRule getSchedulingRule() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation#getOperationExecutionFlags() - */ - public int getOperationExecutionFlags() { - return IWorkspace.AVOID_UPDATE; - } - - /** - * 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. - */ - public final void setEnvironment(IEnvironment env) { - environment = env; - } - - /** - * An operation can call this method to get the environment - * that has been set by the operations framework. - * @return returns an environment. - */ - public final IEnvironment getEnvironment() { - return environment; - } - - /** - * An operation can specify a list of operations that should run - * before this operation. Subclasses can override this method to - * provide these operations. The operations provided will be - * executed in the order specified in the list. - * @return returns a list of data model operations or null. - * Null indicates that there are no pre operations. - */ - public List getPreOperations() - { - return null; - } - - /** - * An operation can specify a list of operations that should run - * after this operation. Subclasses can override this method to - * provide these operations. The operations provided will be - * executed in the order specified in the list. - * @return returns a list of data model operations or null. - * Null indicates that there are no post operations. - */ - public List getPostOperations() - { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.OK_STATUS; - } - - 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 02df2f729..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelFactory.java +++ /dev/null @@ -1,108 +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 org.eclipse.wst.common.frameworks.internal.datamodel.DataModelExtensionReader; -import org.eclipse.wst.common.frameworks.internal.datamodel.DataModelImpl; - -/** - * <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> - * Looks up the appropriate IDataModelProvider using the name of the specified class. This - * method is equavalent to <code>createDataModel(dataModelProviderClassID.getName())</code>. - * </p> - * - * @param dataModelProviderClass - * the class whose name is the id of the IDataModelProvider - * @return a new IDataModel - */ - public static IDataModel createDataModel(Class dataModelProviderClass) { - return createDataModel(dataModelProviderClass.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 2154eccfe..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelPropertyDescriptor.java +++ /dev/null @@ -1,140 +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$ - } - - 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 7c37928d4..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModel.java +++ /dev/null @@ -1,721 +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.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 primaryly 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. - * </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); - - /** - * Returns <code>true</code> if a nested model exists (at the top level only) with the - * specified name and <code>false</code> otherwise. - * - * @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); - - /** - * 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>). - * - * @param nestedModelName - * the name of the nested IDataModel to get. - * @return the nested IDataModel - */ - public IDataModel getNestedModel(String nestedModelName); - - /** - * Returns a Collection of all nested IDataModels, or an empty Collection if none exist. - * - * @return a Collection of all nested IDataModels, or an empty Collection if none exist. - */ - public Collection getNestedModels(); - - /** - * Returns a Collection of all nested IDataModels names, or an empty Collection if none exist. - * - * @return a Collection of all nested IDataModels names, or an empty Collection if none exist. - */ - public Collection getNestedModelNames(); - - /** - * Returns a Collection of all nesting (the inverse of nested) IDataModels, or an empty - * Collection if none exist. - * - * @return a Collection of all nesting (the inverse of nested) IDataModels, or an empty - * Collection if none exist. - */ - public Collection getNestingModels(); - - /** - * Returns a Collection of all base properties (not including nested properties), or an empty - * Collection if none exist. - * - * @return a Collection of all base properties (not including nested properties), or an empty - * Collection if none exist. - */ - public Collection getBaseProperties(); - - /** - * Returns a Collection of all properties of recursively nested IDataModels, or an empty - * Collection if none exist. - * - * @return a Collection of all properties of recursively nested IDataModels, or an empty - * Collection if none exist. - */ - public Collection getNestedProperties(); - - /** - * Returns a Collection of all properties (the union of getBaseProperties() and - * getNestedProperties()), or an empty Collection if none exist. - * - * @return a Collection of all properties (the union of getBaseProperties() and - * getNestedProperties()), or an empty Collection if none exist. - */ - public Collection getAllProperties(); - - /** - * 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. - * - * @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); - - /** - * Returns <code>true</code> if the specified propertyName is a valid propertyName for this - * DataModel or any of its (recursively) nested IDataModels. - * - * @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); - - /** - * 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. - * - * @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); - - /** - * 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. - * - * @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 8029d64ef..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java +++ /dev/null @@ -1,102 +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.List; -import java.util.Set; -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> - * - * @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(); - - public Set getDataModelIDs(); - - public ISchedulingRule getSchedulingRule(); - - public int getOperationExecutionFlags(); - - /** - * 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. - */ - public void setEnvironment( IEnvironment environment ); - - /** - * An operation can specify a list of operations that should run - * before this operation. Subclasses can override this method to - * provide these operations. The operations provided will be - * executed in the order specified in the list. - * @return returns a list of data model operations or null. - * Null indicates that there are no pre operations. - */ - public List getPreOperations(); - - /** - * An operation can specify a list of operations that should run - * after this operation. Subclasses can override this method to - * provide these operations. The operations provided will be - * executed in the order specified in the list. - * @return returns a list of data model operations or null. - * Null indicates that there are no post operations. - */ - public List getPostOperations(); -} 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 a52d3cf31..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProperties.java +++ /dev/null @@ -1,45 +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> - * IDataModelProperties provides the base interface for all Data Model Properties interfaces. - * The interface itself can be used to access an instance of the IDataModel and IDataModelProvider which will be registered - * against with the interface. IDataModels are not meant to be instantiated directly, rather they are built from an - * IDataModelProvider. In this way the user will call to the DataModelFactory passing in the interface, - * which will return the correct IDataModel. - * </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 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 63a272314..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProvider.java +++ /dev/null @@ -1,119 +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.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. - * - * - * @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/DataModelManager.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/DataModelManager.java deleted file mode 100644 index 5396fd7b8..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/DataModelManager.java +++ /dev/null @@ -1,71 +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 java.util.HashMap; -import java.util.Iterator; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class DataModelManager { - private IDataModel rootDataModel; - private HashMap nestedModelEntries; // Element = java.lang.Integer - - public DataModelManager(IDataModel rootDataModel) { - this.rootDataModel = rootDataModel; - nestedModelEntries = new HashMap(); - - Iterator names = this.rootDataModel.getNestedModelNames().iterator(); - - while (names.hasNext()) { - String nestedModelName = (String) names.next(); - nestedModelEntries.put(nestedModelName, new Integer(1)); - } - } - - public IDataModel getDataModel() { - return rootDataModel; - } - - public void addNestedDataModel(String dataModelID) { - Integer referenceCount = (Integer) nestedModelEntries.get(dataModelID); - - if (referenceCount == null) { - // This nested data model is not currently in the root data model. - // Therefore, we need to create one and add it as a nested data model. - IDataModel dataModel = DataModelFactory.createDataModel(dataModelID); - - if (dataModel != null) { - rootDataModel.addNestedModel(dataModelID, dataModel); - nestedModelEntries.put(dataModelID, new Integer(1)); - } - } else { - // We already have this data model nested in the root data model - // so just increment the reference count. - nestedModelEntries.put(dataModelID, new Integer(referenceCount.intValue() + 1)); - } - } - - public void removeNestedDataModel(String dataModelID) { - Integer referenceCount = (Integer) nestedModelEntries.get(dataModelID); - - if (referenceCount != null) { - int newRefCount = referenceCount.intValue() - 1; - - if (newRefCount == 0) { - // Remove the nested data model. - nestedModelEntries.remove(dataModelID); - rootDataModel.removeNestedModel(dataModelID); - } else { - // Set the table entry to the decremented ref count value. - nestedModelEntries.put(dataModelID, new Integer(newRefCount)); - } - } - } -} 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/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/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/OperationListener.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationListener.java deleted file mode 100644 index e6efab782..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationListener.java +++ /dev/null @@ -1,21 +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.frameworks.datamodel.IDataModelOperation; - -public interface OperationListener { - /** - * - * @param operation - * the operation for this traversal event. - * @return return true if the traversal of operations should continue. - */ - public boolean notify(IDataModelOperation operation); -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationManager.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationManager.java deleted file mode 100644 index 98ae49d26..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationManager.java +++ /dev/null @@ -1,472 +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 java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.Stack; -import java.util.Vector; - -import org.eclipse.core.commands.ExecutionException; -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.environment.IEnvironment; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.datamodel.IWorkspaceRunnableWithStatus; -import org.eclipse.wst.common.frameworks.internal.operations.ComposedExtendedOperationHolder; -import org.eclipse.wst.common.frameworks.internal.operations.OperationStatus; - -public class OperationManager { - private IDataModel dataModel; - private DataModelManager dataModelManager; - private TableEntry rootOperation; - private HashMap operationTable; - private Stack runStopList; - private IProgressMonitor monitor; - private IAdaptable adaptable; - private OperationStatus status; - private OperationListener preExecuteListener; - private OperationListener postExecuteListener; - private OperationListener undoExecuteListener; - private IEnvironment environment; - - public OperationManager(DataModelManager aDataModelManager, IDataModelOperation aRootOperation, IEnvironment aEnvironment) { - if (aRootOperation == null) - aRootOperation = new NullOperation(); - - TableEntry entry = new TableEntry(aRootOperation); - - dataModelManager = aDataModelManager; - dataModel = dataModelManager.getDataModel(); - rootOperation = entry; - operationTable = new HashMap(); - runStopList = new Stack(); - operationTable.put(aRootOperation.getID(), entry); - environment = aEnvironment; - addExtendedOperations(aRootOperation); - - OperationListener defaultListener = new OperationListener() { - public boolean notify(IDataModelOperation operation) { - return true; - } - }; - - preExecuteListener = defaultListener; - postExecuteListener = defaultListener; - undoExecuteListener = defaultListener; - } - - public void setProgressMonitor(IProgressMonitor monitor) { - this.monitor = monitor; - } - - public void setAdaptable(IAdaptable adaptable) { - this.adaptable = adaptable; - } - - public void addExtendedPreOperation(String operationId, IDataModelOperation insertOperation) { - TableEntry entry = (TableEntry) operationTable.get(operationId); - - if (entry != null) { - TableEntry newEntry = new TableEntry(insertOperation); - - entry.preOperations.add(newEntry); - operationTable.put(insertOperation.getID(), newEntry); - } - } - - public void addExtendedPostOperation(String operationId, IDataModelOperation insertOperation) { - TableEntry entry = (TableEntry) operationTable.get(operationId); - - if (entry != null) { - TableEntry newEntry = new TableEntry(insertOperation); - - entry.postOperations.add(newEntry); - operationTable.put(insertOperation.getID(), newEntry); - } - } - - public void setPreExecuteListener(OperationListener listener) { - if (listener != null) - preExecuteListener = listener; - } - - public void setPostExecuteListener(OperationListener listener) { - if (listener != null) - postExecuteListener = listener; - } - - public void setUndoExecuteListener(OperationListener listener) { - if (listener != null) - undoExecuteListener = listener; - } - - public IStatus runOperations() { - boolean continueRun = true; - RunListEntry runEntry = startNewRun(); - - status = null; - - // All operations have already been run so just return OK. - if (runEntry.stackEntries.empty()) - return Status.OK_STATUS; - - while (continueRun) { - continueRun = runOperationsUntilStopped(runEntry) && !runEntry.stackEntries.empty(); - } - - if (status != null && status.getSeverity() == IStatus.ERROR) { - undoLastRun(); - } - return status; - } - - public void undoLastRun() { - if (!runStopList.empty()) { - RunListEntry runListEntry = (RunListEntry) runStopList.pop(); - - for (int index = runListEntry.executedOperations.size() - 1; index >= 0; index--) { - IDataModelOperation operation = (IDataModelOperation) runListEntry.executedOperations.elementAt(index); - Set dataModelIDs = operation.getDataModelIDs(); - - if( dataModelIDs != null && dataModelIDs.size() > 0 ) - { - Iterator ids = dataModelIDs.iterator(); - - while( ids.hasNext() ) - { - String dataModelID = (String)ids.next(); - dataModelManager.removeNestedDataModel(dataModelID); - } - } - - try { - undoExecuteListener.notify(operation); - } catch (Throwable exc) { - // TODO report undo notify exception. - } - - if (operation.canUndo()) { - try { - runOperation(operation, true); - } catch (Throwable exc) { - // TODO report an undo exception here. - } - } - } - } - } - - private RunListEntry startNewRun() { - RunListEntry newEntry = null; - - if (runStopList.empty()) { - newEntry = new RunListEntry(rootOperation); - } else { - RunListEntry topRunList = (RunListEntry) runStopList.peek(); - newEntry = new RunListEntry(topRunList); - } - - runStopList.push(newEntry); - - return newEntry; - } - - private boolean runOperationsUntilStopped(RunListEntry runListEntry) { - StackEntry stackEntry = (StackEntry) runListEntry.stackEntries.peek(); - boolean continueRun = true; - - // Run extended pre operations. - for (int index = stackEntry.preOperationIndex + 1; continueRun && index < stackEntry.tableEntry.preOperations.size(); index++) { - TableEntry tableEntry = (TableEntry) stackEntry.tableEntry.preOperations.elementAt(index); - - runListEntry.stackEntries.push(new StackEntry(tableEntry)); - stackEntry.preOperationIndex = index; - continueRun = runOperationsUntilStopped(runListEntry); - } - - if( continueRun && stackEntry.preOpChildIndex == -1 ) stackEntry.addPreOpChildren(); - - // Run child pre operations. - for (int index = stackEntry.preOpChildIndex + 1; continueRun && index < stackEntry.preOpChildren.size(); index++) { - TableEntry tableEntry = (TableEntry) stackEntry.preOpChildren.elementAt(index); - - runListEntry.stackEntries.push(new StackEntry(tableEntry)); - stackEntry.preOpChildIndex = index; - continueRun = runOperationsUntilStopped(runListEntry); - } - - if (continueRun && !stackEntry.operationExecuted) { - IDataModelOperation operation = stackEntry.tableEntry.operation; - - try { - continueRun = preExecuteListener.notify(operation); - - if (continueRun) { - Set dataModelIDs = operation.getDataModelIDs(); - - if (dataModelIDs != null && dataModelIDs.size() > 0 ) - { - Iterator ids = dataModelIDs.iterator(); - - while( ids.hasNext() ) - { - String dataModelID = (String)ids.next(); - dataModelManager.addNestedDataModel(dataModelID); - } - } - - operation.setDataModel(dataModel); - operation.setEnvironment( environment ); - setStatus(runOperation(operation, false)); - runListEntry.executedOperations.add(operation); - stackEntry.operationExecuted = true; - continueRun = postExecuteListener.notify(operation); - } - } catch (Throwable exc) { - setStatus(new Status(IStatus.ERROR, "id", 0, exc.getMessage() == null ? exc.toString() : exc.getMessage(), exc)); - } - - if (status != null && status.getSeverity() == IStatus.ERROR) { - // This isn't really true, but it will cause the run operations to stop. - continueRun = false; - } - } - - if( continueRun && stackEntry.postOpChildIndex == -1 ) stackEntry.addPostOpChildren(); - - // Run child post operations. - for (int index = stackEntry.postOpChildIndex + 1; continueRun && index < stackEntry.postOpChildren.size(); index++) { - TableEntry tableEntry = (TableEntry) stackEntry.postOpChildren.elementAt(index); - - stackEntry.postOpChildIndex = index; - runListEntry.stackEntries.push(new StackEntry(tableEntry)); - continueRun = runOperationsUntilStopped(runListEntry); - } - - // Run extended post operations. - for (int index = stackEntry.postOperationIndex + 1; continueRun && index < stackEntry.tableEntry.postOperations.size(); index++) { - TableEntry tableEntry = (TableEntry) stackEntry.tableEntry.postOperations.elementAt(index); - - stackEntry.postOperationIndex = index; - runListEntry.stackEntries.push(new StackEntry(tableEntry)); - continueRun = runOperationsUntilStopped(runListEntry); - } - - // If we are have run the pre ops, this operation, and - // the post ops, we should pop this entry off the stack. - // Also, if continueRun is false we don't want to pop the stack since we will want to come - // back to this entry later. - if (continueRun) { - runListEntry.stackEntries.pop(); - } - - return continueRun; - } - - private IStatus runOperation(final IDataModelOperation operation, final boolean isUndo) { - IWorkspaceRunnableWithStatus workspaceRunnable = new IWorkspaceRunnableWithStatus(adaptable) { - public void run(IProgressMonitor pm) throws CoreException { - try { - if (isUndo) { - this.setStatus(operation.undo(monitor, getInfo())); - } else { - this.setStatus(operation.execute(monitor, getInfo())); - } - } catch (Throwable exc) { - exc.printStackTrace(); - } - } - }; - - ISchedulingRule rule = operation.getSchedulingRule(); - - try { - if (rule == null) { - ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor); - } else { - ResourcesPlugin.getWorkspace().run(workspaceRunnable, rule, operation.getOperationExecutionFlags(), monitor); - } - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return workspaceRunnable.getStatus(); - } - - private void setStatus(IStatus newStatus) { - if (status == null) { - status = new OperationStatus(newStatus.getMessage(), newStatus.getException()); - status.setSeverity(newStatus.getSeverity()); - status.add(newStatus); - } else { - status.add(newStatus); - } - } - - private void addExtendedOperations(IDataModelOperation operation) { - ComposedExtendedOperationHolder extendedOps = ComposedExtendedOperationHolder.createExtendedOperationHolder(operation.getID()); - - ArrayList preOps = null; - ArrayList postOps = null; - - if (extendedOps != null) { - preOps = extendedOps.getPreOps(); - postOps = extendedOps.getPostOps(); - } - - if (preOps == null) - preOps = new ArrayList(); - if (postOps == null) - postOps = new ArrayList(); - - for (int index = 0; index < preOps.size(); index++) { - IDataModelOperation newOperation = (IDataModelOperation) preOps.get(index); - - addExtendedPreOperation(operation.getID(), newOperation); - addExtendedOperations(newOperation); - } - - for (int index = 0; index < postOps.size(); index++) { - IDataModelOperation newOperation = (IDataModelOperation) postOps.get(index); - - addExtendedPostOperation(operation.getID(), newOperation); - addExtendedOperations(newOperation); - } - } - - private class RunListEntry { - public Stack stackEntries; - public Vector executedOperations; - - public RunListEntry(TableEntry newEntry) { - stackEntries = new Stack(); - executedOperations = new Vector(); - stackEntries.push(new StackEntry(newEntry)); - } - - public RunListEntry(RunListEntry oldList) { - stackEntries = new Stack(); - executedOperations = new Vector(); - - for (int index = 0; index < oldList.stackEntries.size(); index++) { - StackEntry oldEntry = (StackEntry) oldList.stackEntries.elementAt(index); - stackEntries.add(new StackEntry(oldEntry)); - } - } - } - - private class StackEntry { - public int preOperationIndex; - public int postOperationIndex; - public int preOpChildIndex; - public int postOpChildIndex; - public boolean operationExecuted; - public Vector preOpChildren; - public Vector postOpChildren; - public TableEntry tableEntry; - - public StackEntry(TableEntry newTableEntry) { - preOperationIndex = -1; - postOperationIndex = -1; - operationExecuted = false; - preOpChildIndex = -1; - postOpChildIndex = -1; - tableEntry = newTableEntry; - } - - public StackEntry(StackEntry newStackEntry) { - preOperationIndex = newStackEntry.preOperationIndex; - postOperationIndex = newStackEntry.postOperationIndex; - operationExecuted = newStackEntry.operationExecuted; - tableEntry = newStackEntry.tableEntry; - preOpChildIndex = newStackEntry.preOpChildIndex; - postOpChildIndex = newStackEntry.postOpChildIndex; - preOpChildren = newStackEntry.preOpChildren == null ? null :new Vector( newStackEntry.preOpChildren ); - postOpChildren = newStackEntry.postOpChildren == null ? null : new Vector( newStackEntry.postOpChildren ); - } - - public void addPreOpChildren() - { - List preOps = tableEntry.operation.getPreOperations(); - - preOpChildren = new Vector(); - - if( preOps != null ) - { - for( int index = 0; index < preOps.size(); index++ ) - { - IDataModelOperation op = (IDataModelOperation)preOps.get( index ); - TableEntry newEntry = new TableEntry(op); - - preOpChildren.add( newEntry ); - operationTable.put( op.getID(), newEntry ); - addExtendedOperations( op ); - } - } - } - - public void addPostOpChildren() - { - List postOps = tableEntry.operation.getPostOperations(); - - postOpChildren = new Vector(); - - if( postOps != null ) - { - for( int index = 0; index < postOps.size(); index++ ) - { - IDataModelOperation op = (IDataModelOperation)postOps.get( index ); - TableEntry newEntry = new TableEntry(op); - - postOpChildren.add( newEntry ); - operationTable.put( op.getID(), newEntry ); - addExtendedOperations( op ); - } - } - } - } - - private class TableEntry { - public IDataModelOperation operation; - public Vector preOperations; - public Vector postOperations; - - public TableEntry(IDataModelOperation newOperation) { - operation = newOperation; - preOperations = new Vector(3); - postOperations = new Vector(3); - } - } - - private class NullOperation extends AbstractDataModelOperation { - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.OK_STATUS; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.OK_STATUS; - } - - 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/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 a9c07ce67..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.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.IWFTWrappedException; - -/** - * 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: " - Logger.getLogger().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 7dee26d2a..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveHandlerRegister.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.internal; - -import org.eclipse.jem.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/WTPPlugin.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPPlugin.java deleted file mode 100644 index 37c04a030..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPPlugin.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 10, 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.util.ResourceBundle; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.util.logger.proxyrender.DefaultPluginTraceRenderer; -import org.eclipse.jem.util.logger.proxyrender.IMsgLogger; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WorkbenchUtil; -import org.osgi.framework.BundleContext; - -public abstract class WTPPlugin extends Plugin implements IMsgLogger { - protected static Logger logger = null; - protected static WTPPlugin instance = null; - public ResourceBundle resourceBundle; - - /** - * @param descriptor - */ - public WTPPlugin() { - super(); - instance = this; - } - - public Logger getMsgLogger() { - if (logger == null) { - logger = Logger.getLogger(getPluginID()); - setRenderer(logger); - } - return logger; - } - - /** - * @param aLogger - */ - protected void setRenderer(Logger aLogger) { - new DefaultPluginTraceRenderer(aLogger); - } - - public Logger getLogger() { - return getMsgLogger(); - } - public static boolean isPlatformCaseSensitive() { - return Platform.OS_MACOSX.equals(Platform.getOS()) ? false : new - java.io.File("a").compareTo(new java.io.File("A")) != 0; - } - - public abstract String getPluginID(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugin#startup() - */ - 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 d10281e6c..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPProjectUtilities.java +++ /dev/null @@ -1,155 +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 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.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$ //$NON-NLS-3$ - String[] temp = newNatures; - newNatures = new String[newsize]; - System.arraycopy(temp, 0, newNatures, 0, newsize); - description.setNatureIds(newNatures); - 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 cd2aba830..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedException.java +++ /dev/null @@ -1,81 +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. - */ - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Prints the exception to System.err. If we have a nested exception, print its stack. - */ - 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. - */ - 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 35ed923aa..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedRuntimeException.java +++ /dev/null @@ -1,115 +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 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; - } - - /** - * Print out a stack trace to the system err. - */ - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Prints the exception to System.err. If we have a nested exception, print its stack. - */ - 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. - */ - 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; - } -}
\ No newline at end of file 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 3538ea4ce..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.jem.util.logger.proxy.Logger; - -/** - * @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() { - for (int i = 0; i < listeners.length; i++) { - return listeners[i].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) { - for (int i = 0; i < listeners.length; i++) { - return listeners[i].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$ - Logger.getLogger().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 86adbc67a..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.jem.util.RegistryReader; -import org.eclipse.jem.util.logger.proxy.Logger; -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); - } - - public boolean readElement(IConfigurationElement element) { - if (element.getName().equals(PROVIDER_ELEMENT)) { - String id = element.getAttribute(ATTRIBUTE_ID); - if (null == id || id.trim().length() == 0) { - Logger.getLogger().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) { - Logger.getLogger().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) { - Logger.getLogger().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) { - Logger.getLogger().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) { - Logger.getLogger().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) { - Logger.getLogger().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)) { - Logger.getLogger().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)) { - Logger.getLogger().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) { - Logger.getLogger().log(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) { - Logger.getLogger().log(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) { - Logger.getLogger().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 eb7027a60..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelImpl.java +++ /dev/null @@ -1,464 +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.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(String propertyName, int flag) { - if (flag == DEFAULT_CHG) { - if (isPropertySet(propertyName)) { - return; - } - flag = VALUE_CHG; - } - notifyListeners(new DataModelEvent(this, propertyName, flag)); - } - - 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 != null && !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 getDefaultOperation() { - IDataModelOperation providerOp = provider.getDefaultOperation(); - if (null == providerOp) { - providerOp = new AbstractDataModelOperation(this) { - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return OK_STATUS; - } - }; - } - return new ExtendableOperationImpl(providerOp); - } - - 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/ExtendableOperationImpl.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/ExtendableOperationImpl.java deleted file mode 100644 index 38391aa87..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/ExtendableOperationImpl.java +++ /dev/null @@ -1,333 +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.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.List; -import java.util.Set; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.IUndoContext; -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.SubProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -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 final class ExtendableOperationImpl implements IDataModelOperation { - - private IDataModelOperation rootOperation; - private List appendedOperations; - private IEnvironment environment; - - private OperationStatus opStatus; - - private static Hashtable threadToExtendedOpControl; - - private class ExtendedOpControl { - private boolean allowExtensions; - List restrictedExtensions; - - public ExtendedOpControl(boolean allowExtensions, List restrictedExtensions) { - this.allowExtensions = allowExtensions; - this.restrictedExtensions = restrictedExtensions; - } - - public boolean shouldExecute(String operationID) { - return allowExtensions && !restrictedExtensions.contains(operationID); - } - } - - public ExtendableOperationImpl(IDataModelOperation rootOperation) { - this.rootOperation = rootOperation; - if (null == rootOperation) { - throw new NullPointerException(); - } - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) { - return null; - } - - public Set getDataModelIDs() { - return new HashSet(); - } - - /** - * @return - */ - public ISchedulingRule getSchedulingRule() { - return rootOperation.getSchedulingRule(); - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) { - return null; - } - - public final void addStatus(IStatus aStatus) { - if (opStatus == null) { - opStatus = new OperationStatus(aStatus.getMessage(), aStatus.getException()); - opStatus.setSeverity(aStatus.getSeverity()); - opStatus.add(aStatus); - } else { - opStatus.add(aStatus); - } - } - - private void addExtendedStatus(IStatus aStatus) { - if (opStatus == null) { - opStatus = new OperationStatus(new IStatus[]{WTPCommonPlugin.OK_STATUS}); - } - opStatus.addExtendedStatus(aStatus); - } - - public void appendOperation(IDataModelOperation appendedOperation) { - if (appendedOperations == null) { - appendedOperations = new ArrayList(3); - } - appendedOperations.add(appendedOperation); - } - - /** - * Initiates a batch of changes, by invoking the execute() method as a workspace runnable. - * - * @param monitor - * the progress monitor to use to display progress - * @exception InvocationTargetException - * wraps any CoreException, runtime exception or error thrown by the execute() - * method - * @see WorkspaceModifyOperation - this class was directly copied from it - */ - public IStatus execute(IProgressMonitor monitor, IAdaptable info) { - // final InvocationTargetException[] iteHolder = new InvocationTargetException[1]; - IWorkspaceRunnableWithStatus workspaceRunnable = new IWorkspaceRunnableWithStatus(info) { - public void run(IProgressMonitor pm) throws CoreException { - setStatus(doExecute(pm, getInfo())); - } - }; - ISchedulingRule rule = getSchedulingRule(); - try { - if (rule == null) - ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor); - else - ResourcesPlugin.getWorkspace().run(workspaceRunnable, rule, getOperationExecutionFlags(), monitor); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - return workspaceRunnable.getStatus(); - } - - public IStatus doExecute(IProgressMonitor monitor, IAdaptable info) { - if (null == threadToExtendedOpControl) { - threadToExtendedOpControl = new Hashtable(); - } - final Thread currentThread = Thread.currentThread(); - final boolean isTopLevelOperation = !threadToExtendedOpControl.containsKey(currentThread); - try { - if (isTopLevelOperation) { - boolean allowExtensions = getDataModel() == null ? true : getDataModel().getBooleanProperty(IDataModelProperties.ALLOW_EXTENSIONS); - List restrictedExtensions = getDataModel() == null ? Collections.EMPTY_LIST : (List) getDataModel().getProperty(IDataModelProperties.RESTRICT_EXTENSIONS); - ExtendedOpControl extendedOpControl = new ExtendedOpControl(allowExtensions, restrictedExtensions); - threadToExtendedOpControl.put(currentThread, extendedOpControl); - } - - ComposedExtendedOperationHolder extOpHolder = ComposedExtendedOperationHolder.createExtendedOperationHolder(rootOperation.getID()); - IStatus preOpStatus = runPreOps(monitor, extOpHolder, info); - try { - addStatus(rootOperation.execute(monitor, info)); - } catch (ExecutionException e1) { - addStatus(new Status(IStatus.ERROR, "org.eclipse.wst.common.frameworks.internal", 0, e1.getMessage(), e1)); //$NON-NLS-1$ - } - - IStatus postOpStatus = runPostOps(monitor, extOpHolder, info); - if (null != preOpStatus) { - addExtendedStatus(preOpStatus); - } - if (null != postOpStatus) { - addExtendedStatus(postOpStatus); - } - if (appendedOperations != null) { - OperationStatus composedStatus = null; - for (int i = 0; i < appendedOperations.size(); i++) { - try { - ExtendableOperationImpl op = new ExtendableOperationImpl((IDataModelOperation) appendedOperations.get(i)); - IStatus status = op.execute(new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK), info); - if (composedStatus == null) - composedStatus = new OperationStatus(new IStatus[]{status}); - else - composedStatus.add(status); - } catch (Exception e) { - Logger.getLogger().logError(e); - } - } - if (null != composedStatus) { - addStatus(composedStatus); - } - } - } finally { - if (isTopLevelOperation) { - threadToExtendedOpControl.remove(currentThread); - } - } - - return opStatus; - } - - private IStatus runPreOps(IProgressMonitor pm, ComposedExtendedOperationHolder extOpHolder, IAdaptable info) { - IStatus preOpStatus = null; - if ((extOpHolder != null) && extOpHolder.hasPreOps()) { - preOpStatus = runExtendedOps(extOpHolder.getPreOps(), pm, info); - } - return preOpStatus; - } - - private IStatus runPostOps(IProgressMonitor pm, ComposedExtendedOperationHolder extOpHolder, IAdaptable info) { - IStatus postOpStatus = null; - if ((extOpHolder != null) && extOpHolder.hasPostOps()) { - postOpStatus = runExtendedOps(extOpHolder.getPostOps(), pm, info); - } - - return postOpStatus; - } - - private IStatus runExtendedOps(List opList, IProgressMonitor pm, IAdaptable info) { - IDataModel rootDataModel = rootOperation.getDataModel(); - IDataModelOperation nestedOp = null; - OperationStatus returnStatus = null; - IStatus localStatus; - String opId = null; - ExtendedOpControl opControl = (ExtendedOpControl) threadToExtendedOpControl.get(Thread.currentThread()); - for (int i = 0; i < opList.size(); i++) { - nestedOp = (IDataModelOperation) opList.get(i); - opId = nestedOp.getID(); - if (opControl.shouldExecute(nestedOp.getClass().getName()) && opControl.shouldExecute(opId)) { - try { - boolean shouldExtendedRun = true; - - List extendedContext = rootDataModel.getExtendedContext(); - for (int contextCount = 0; shouldExtendedRun && contextCount < extendedContext.size(); contextCount++) { - IProject project = (IProject) AdaptabilityUtility.getAdapter(extendedContext.get(contextCount), IProject.class); - if (null != project && !IEnablementManager.INSTANCE.getIdentifier(opId, project).isEnabled()) { - shouldExtendedRun = false; - } - } - if (shouldExtendedRun) { - nestedOp.setDataModel(rootDataModel); - ExtendableOperationImpl extendedOp = new ExtendableOperationImpl(nestedOp); - localStatus = extendedOp.doExecute(new SubProgressMonitor(pm, IProgressMonitor.UNKNOWN), info); - } else - localStatus = null; - } catch (Exception e) { - localStatus = new Status(IStatus.ERROR, WTPCommonPlugin.PLUGIN_ID, 0, WTPResourceHandler.getString("25", new Object[]{nestedOp.getClass().getName()}), e); //$NON-NLS-1$ - } - if (localStatus != null) { - if (returnStatus == null) { - returnStatus = new OperationStatus(new IStatus[]{localStatus}); - } else { - returnStatus.add(localStatus); - } - } - } - } - return returnStatus; - } - - public void dispose() { - } - - public boolean canExecute() { - return rootOperation.canExecute(); - } - - public boolean canRedo() { - return rootOperation.canRedo(); - } - - public boolean canUndo() { - return rootOperation.canUndo(); - } - - 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 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 env) { - environment = env; - } - - public IEnvironment getEnvironment() { - return environment; - } - - public List getPreOperations() - { - return null; - } - - public List getPostOperations() - { - return null; - } -} 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/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 a6dbbd934..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifier.java +++ /dev/null @@ -1,233 +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); - - } - - 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; - } - - 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) { - functionGroupIds = Util.safeCopy(functionGroupIds, String.class); - - if (!Util.equals(functionGroupIds, this.functionGroupIds)) { - this.functionGroupIds = functionGroupIds; - 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; - } - - 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 d90b19cc3..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifierEvent.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 - *******************************************************************************/ -/* - * 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() - */ - 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 549484442..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementManager.java +++ /dev/null @@ -1,171 +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 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.jem.util.logger.proxy.Logger; -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(); - if (project != null && !project.isAccessible()) project = null; - - EnablementIdentifier identifier = null; - synchronized(this) { - Map identifiersById = getIdentifiersById(project); - - identifier = (EnablementIdentifier) identifiersById.get(identifierId); - - if (identifier == null) { - identifier = createIdentifier(identifierId, project); - updateIdentifier(identifier); - identifiersById.put(identifierId, 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); - Logger.getLogger().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 e2fd9382b..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroup.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.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.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; - - -/** - * @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) { - Logger.getLogger().logError(WTPResourceHandler.getString("29", new Object[]{GROUP_INTIALIZER_CLASS_ATTR, getInitalizerClassName(), getDeclaringExtensionName()}) + "\r\n"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-4$ - Logger.getLogger().logError(e); - } - return groupInterface; - } - - 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) { - Logger.getLogger().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) { - functionGroupPatternBindings = Util.safeCopy(functionGroupPatternBindings, FunctionGroupPatternBinding.class); - - if (!Util.equals(functionGroupPatternBindings, this.functionGroupPatternBindings)) { - this.functionGroupPatternBindings = functionGroupPatternBindings; -// this.functionGroupPatternBindingsAsArray = (FunctionGroupPatternBinding[]) this.functionGroupPatternBindings.toArray(new FunctionGroupPatternBinding[this.functionGroupPatternBindings.size()]); - - 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 d38777183..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupPatternBinding.java +++ /dev/null @@ -1,98 +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; - } - - 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; - } - - 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; - } - - 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 996c92c68..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupRegistry.java +++ /dev/null @@ -1,255 +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.jem.util.RegistryReader; -import org.eclipse.jem.util.logger.proxy.Logger; -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. - * - * @author mdelder/blancett - */ -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 - */ - 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); - } - - } - - 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) { - Logger.getLogger().logError(new IllegalArgumentException(WTPResourceHandler.getString("28", new Object[]{groupID1}))); //$NON-NLS-1$ - return -1; - } - if (group2 == null) { - Logger.getLogger().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 454c94c82..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementManager.java +++ /dev/null @@ -1,59 +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 - * - * 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 org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.util.UIContextDetermination; - -/** - * @author schacher - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -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 0df26cf21..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IdentifiableComparator.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.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) - */ - public boolean equals(Object obj) { - return obj instanceof IdentifiableComparator; - } - - 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 740270a0f..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 = Collections.unmodifiableList(new ArrayList(list)); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) - assertInstance(iterator.next(), c, allowNullElements); - - return list; - } - - 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 = Collections.unmodifiableMap(new HashMap(map)); - Iterator iterator = map.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - assertInstance(entry.getKey(), keyClass, allowNullKeys); - assertInstance(entry.getValue(), valueClass, allowNullValues); - } - - return map; - } - - 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 = Collections.unmodifiableSet(new HashSet(set)); - Iterator iterator = set.iterator(); - - while (iterator.hasNext()) - assertInstance(iterator.next(), c, allowNullElements); - - return set; - } - - 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 = Collections.unmodifiableSortedMap(new TreeMap(sortedMap)); - Iterator iterator = sortedMap.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - assertInstance(entry.getKey(), keyClass, allowNullKeys); - assertInstance(entry.getValue(), valueClass, allowNullValues); - } - - return sortedMap; - } - - 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 = Collections.unmodifiableSortedSet(new TreeSet(sortedSet)); - Iterator iterator = sortedSet.iterator(); - - while (iterator.hasNext()) - assertInstance(iterator.next(), c, allowNullElements); - - return sortedSet; - } - - 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 8b754b534..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.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.frameworks.internal.enablement.EnablementManager; - -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) { - Logger.getLogger().logError(e); - } - try { - postOp = currentExt.getPostOperation(); - if (postOp != null) { - extOperationHolder.addPostOperation(postOp); - } - } catch (CoreException e) { - Logger.getLogger().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/IProjectCreationProperties.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IProjectCreationProperties.java deleted file mode 100644 index 214e6e59b..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IProjectCreationProperties.java +++ /dev/null @@ -1,52 +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; - - -/** - * @deprecated use IProjectCreationPropertiesNew - */ -public interface IProjectCreationProperties { - - /** - * 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 = "IProjectCreationProperties.PROJECT_NAME"; //$NON-NLS-1$ - - /** - * An optonal dataModel propertyName for a <code>java.lang.String</code> type. Sets the local - * file system location for the described project. The path must be either an absolute file - * system path, or a relative path whose first segment is the name of a defined workspace path - * variable. The default value is the workspace's default location. - */ - public static final String PROJECT_LOCATION = "IProjectCreationProperties.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 = "IProjectCreationProperties.PROJECT_NATURES"; //$NON-NLS-1$ - - /** - * IProject. An non settable property. This is a conveniece for constructiong getting the - * IProject - */ - public static final String PROJECT = "IProjectCreationProperties.PROJECT"; //$NON-NLS-1$ - - /** - * IProjectDescription. An non settable property. This is a conveniece for constructiong a - * project description. - */ - public static final String PROJECT_DESCRIPTION = "IProjectCreationProperties.PROJECT_DESCRIPTION"; //$NON-NLS-1$ - -} 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 9ab6337e2..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IProjectCreationPropertiesNew.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.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$ - - /** - * 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 31f25db9c..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationExtensionReader.java +++ /dev/null @@ -1,83 +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 Nov 3, 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 java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jem.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> - */ - - 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 0acebf501..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationStatus.java +++ /dev/null @@ -1,63 +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.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); - } - } - - public void setCode(int code) { - super.setCode(code); - } - - public void setException(Throwable exception) { - super.setException(exception); - } - - public void setMessage(String message) { - super.setMessage(message); - } - - public void setSeverity(int severity) { - super.setSeverity(severity); - } - - 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/ProjectCreationDataModelProvider.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationDataModelProvider.java deleted file mode 100644 index ccf044cd2..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationDataModelProvider.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 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 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.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * @deprecated use ProjectCreationDataModelProviderNew instead. - */ -public class ProjectCreationDataModelProvider extends AbstractDataModelProvider implements IProjectCreationProperties { - - public IDataModelOperation getDefaultOperation() { - return new ProjectCreationOperation(model); - } - - public void init() { - super.init(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(PROJECT); - propertyNames.add(PROJECT_NAME); - propertyNames.add(PROJECT_LOCATION); - propertyNames.add(PROJECT_NATURES); - propertyNames.add(PROJECT_DESCRIPTION); - return propertyNames; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(PROJECT_LOCATION)) - return getDefaultLocation(); - else if (propertyName.equals(PROJECT_DESCRIPTION)) - return getProjectDescription(); - return super.getDefaultProperty(propertyName); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - if (propertyValue != null && propertyName.equals(PROJECT_LOCATION)) { - IPath path = getRootLocation(); - if (path.equals(new Path((String) propertyValue))) { - model.setProperty(propertyName, null); - } - model.setProperty(PROJECT_DESCRIPTION, getProjectDescription()); - } else if (propertyName.equals(PROJECT_NAME)) { - IStatus stat = model.validateProperty(PROJECT_NAME); - if (stat != OK_STATUS) - return false; - model.setProperty(PROJECT, getProject()); - model.setProperty(PROJECT_DESCRIPTION, getProjectDescription()); - } - return true; - } - - private String getDefaultLocation() { - IPath path = getRootLocation(); - String projectName = (String) getProperty(PROJECT_NAME); - if (projectName != null) - path = path.append(projectName); - return path.toOSString(); - } - - private IPath getRootLocation() { - return ResourcesPlugin.getWorkspace().getRoot().getLocation(); - } - - private IProjectDescription getProjectDescription() { - String projectName = (String) getProperty(PROJECT_NAME); - IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName); - if (getDataModel().isPropertySet(PROJECT_LOCATION)) { - String projectLocation = (String) getProperty(IProjectCreationProperties.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; - } - - public IStatus validate(String propertyName) { - if (propertyName.equals(PROJECT_NAME)) { - IStatus status = validateName(); - 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 = getStringProperty(PROJECT_LOCATION); - return validateExisting(projectName, projectLoc); - } - return OK_STATUS; - } - - /** - * @param projectName - * @param projectLoc - * @todo Generated comment - */ - private 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; - return OK_STATUS; - } - - private IStatus validateName() { - String name = getStringProperty(PROJECT_NAME); - IStatus status = validateProjectName(name); - if (!status.isOK()) - return status; - if (getProject().exists()) - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_EXISTS_ERROR, new Object[]{name})); - - if (!WTPPlugin.isPlatformCaseSensitive()) { - // now look for a matching case variant in the tree - IResource variant = ((Resource) getProject()).findExistingResourceVariant(getProject().getFullPath()); - if (variant != null) { - // TODO Fix this string - return WTPCommonPlugin.createErrorStatus("Resource already exists with a different case."); //$NON-NLS-1$ - } - } - return OK_STATUS; - } - - private IStatus validateLocation() { - if (getDataModel().isPropertySet(PROJECT_LOCATION)) { - String loc = (String) getProperty(PROJECT_LOCATION); - 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/ProjectCreationDataModelProviderNew.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationDataModelProviderNew.java deleted file mode 100644 index a37559a27..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationDataModelProviderNew.java +++ /dev/null @@ -1,208 +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.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.jem.util.emf.workbench.ProjectUtilities; -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 { - - public IDataModelOperation getDefaultOperation() { - return new ProjectCreationOperation(model); - } - - public void init() { - super.init(); - } - - 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(PROJECT_NATURES); - propertyNames.add(PROJECT_DESCRIPTION); - return propertyNames; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(PROJECT_LOCATION)) { - if (getBooleanProperty(USE_DEFAULT_LOCATION)) { - return null; - } - 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)) { - 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(); - } - - 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)) { - 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) && !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; - } - - 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 - */ - private 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$ - return OK_STATUS; - } - - public static IStatus validateName(String name) { - IStatus status = validateProjectName(name); - if (!status.isOK()) - return status; - IProject project = ProjectUtilities.getProject( name ); - if (project.exists()) - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_EXISTS_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/ProjectCreationOperation.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationOperation.java deleted file mode 100644 index 654f5b099..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationOperation.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 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.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class ProjectCreationOperation extends AbstractDataModelOperation implements IProjectCreationProperties { - - public ProjectCreationOperation(IDataModel dataModel) { - super(dataModel); - } - - 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) { - Logger.getLogger().logError(e); - } finally { - monitor.done(); - } - if (monitor.isCanceled()) - throw new OperationCanceledException(); - return OK_STATUS; - } - - public boolean canUndo() { - return false; - } - - 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 80f12da67..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java +++ /dev/null @@ -1,51 +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 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$ -} 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 c2a4934af..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonPlugin.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 29, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.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; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -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() - */ - public String getPluginID() { - return PLUGIN_ID; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/wtp_common.properties b/plugins/org.eclipse.wst.common.frameworks/src/wtp_common.properties deleted file mode 100644 index f6db565a2..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/wtp_common.properties +++ /dev/null @@ -1,52 +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 -############################################################################### -1=A project already exists with this name and location. -2=The specified EAR project "{0}" is not an EAR project. -3=The EAR project "{0}" has a J2EEVersion of {1} which is not compatable with the specified module version. -4=The EAR project name, "{0}", can not be the same as the project name. -5={0} file name must be entered. -6=The {0} does not exist. -7=An internal error occurred. View log files for details. -8=Project name is invalid. -9=Destination archive should end with {0}. -10=Destination archive is invalid. -11=Destination location is read only. -12=Resource {0} already exists. If you wish to overwrite select the "Overwrite Existing file" option. -13=Project {0} does not exist. -14=The selected version is not supported by the server. -15=Enter a project name. -16=Save problems -17=Save could not be completed. Some related files may have already been saved.\n\nReason -18={0} has been locked. Please ensure the operation is not currently executing. -19=The extendedRoot is null. Make sure that isExtended() returns true. -20=Property not located: -21=Nested model not located: -22=Cannot modify id once it has been set. -23=The id cannot be null. -24=ERROR: -25=Extended Operation failure: {0} -26=The Job completed successfully -27=Exception occurred running job. -28=Group cannot be resolved: -29=Class not found for attribute {0} : {1}, Declaring plugin extension: {2} -30=Function group {0} contains no pattern bindings -31=Project {0} is closed. -32=A project already exists on the file system at this location: {0}. Either use "Import Existing Projects into Workspace" to create a project at this location or delete the contents of {0} from the file system. -33=A model instance may only be nested once under another model instance. -34=Module name cannot be empty. -35=Invalid characters. -36=The module with this name already exists. -37=The module is not supported by this server. -38=Module name is invalid. -39=Enter Source Folder -40=Enter Web content Folder -41=Project names cannot end with white space. -42=Resource already exists with a different case. |