*** empty log message ***
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/WTPDataModelBridgeProvider.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/WTPDataModelBridgeProvider.java
new file mode 100644
index 0000000..dfc7fae
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/WTPDataModelBridgeProvider.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * 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 java.util.Iterator;
+import java.util.List;
+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.jobs.ISchedulingRule;
+import org.eclipse.jem.util.logger.proxy.Logger;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+/**
+ * <p>
+ * This provider acts as wrapper around the old WTPOperationDataModel framework so a exiting
+ * WTPOperationDataModel can work with the new IDataModel framework. This class should be used only
+ * as a temporary solution while porting to the new framework.
+ * </p>
+ * <p>
+ * This provider only allows the old WTPOperationDataModels to run within the new framework; not
+ * vice versa.
+ * </p>
+ * <p>
+ * There are some known limitations:
+ * <ul>
+ * <li> All property names must be defined up front on the WTPOperationDataModel during the
+ * iniitWTPDataModel() method. Any properties added later cause runtime failures. </li>
+ * <li>Any model nested under the WTPOperationDataModel must either be nested during
+ * initWTPDataModel() or must not add any new property names.</li>
+ * <li>Any model nested under the WTPOperationDataModel should not be unnested if doing so will
+ * remove property names with respect to the WTPOperationDataModel</li>
+ * </ul>
+ * </p>
+ *
+ */
+public abstract class WTPDataModelBridgeProvider extends AbstractDataModelProvider {
+
+ /**
+ * A property key used to access the underlying data model. This should be used sparingly.
+ */
+ public static final String WRAPPED_WTP_DATA_MODEL = "WTPDataModelBridgeProvider.WRAPPED_WTP_DATA_MODEL";
+
+ protected WTPOperationDataModel wtpDataModel;
+
+ /**
+ * Subclasses need to return an initiaized WTPOperationDataModel here.
+ *
+ * @return
+ */
+ protected abstract WTPOperationDataModel initWTPDataModel();
+
+ public void init() {
+ }
+
+ public String[] getPropertyNames() {
+ wtpDataModel = initWTPDataModel();
+ wtpDataModel.addListener(new WTPOperationDataModelListener() {
+ public void propertyChanged(WTPOperationDataModelEvent event) {
+ int flag = event.getFlag();
+ String propertyName = event.getPropertyName();
+ switch (flag) {
+ case WTPOperationDataModelEvent.ENABLE_CHG :
+ model.notifyPropertyChange(propertyName, IDataModel.ENABLE_CHG);
+ break;
+ case WTPOperationDataModelEvent.VALID_VALUES_CHG :
+ model.notifyPropertyChange(propertyName, IDataModel.VALID_VALUES_CHG);
+ break;
+ case WTPOperationDataModelEvent.PROPERTY_CHG :
+ if (!wtpDataModel.isSet(propertyName)) {
+ if (model.isPropertySet(propertyName)) {
+ model.setProperty(propertyName, null);
+ }
+ model.notifyPropertyChange(propertyName, IDataModel.DEFAULT_CHG);
+ } else {
+ model.setProperty(propertyName, event.getProperty());
+ model.notifyPropertyChange(propertyName, IDataModel.VALUE_CHG);
+ }
+ break;
+ }
+ }
+ });
+ Set validProperties = wtpDataModel.getValidProperties();
+ String[] propertyNames = new String[validProperties.size() + 1];
+ propertyNames[0] = WRAPPED_WTP_DATA_MODEL;
+ Iterator iterator = validProperties.iterator();
+ for (int i = 1; i < propertyNames.length; i++) {
+ propertyNames[i] = (String) iterator.next();
+ }
+ return propertyNames;
+ }
+
+ public boolean propertySet(String propertyName, Object propertyValue) {
+ if (WRAPPED_WTP_DATA_MODEL.equals(propertyName)) {
+ throw new RuntimeException();
+ }
+ wtpDataModel.setProperty(propertyName, propertyValue);
+ return true;
+ }
+
+ public Object getDefaultProperty(String propertyName) {
+ if (WRAPPED_WTP_DATA_MODEL.equals(propertyName)) {
+ return wtpDataModel;
+ }
+ return wtpDataModel.getDefaultProperty(propertyName);
+ }
+
+ public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) {
+ if (WRAPPED_WTP_DATA_MODEL.equals(propertyName)) {
+ return null;
+ }
+ return convert(wtpDataModel.getPropertyDescriptor(propertyName));
+ }
+
+ public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) {
+ if (WRAPPED_WTP_DATA_MODEL.equals(propertyName)) {
+ return null;
+ }
+ return convert(wtpDataModel.getValidPropertyDescriptors(propertyName));
+ }
+
+ public boolean isPropertyEnabled(String propertyName) {
+ if (WRAPPED_WTP_DATA_MODEL.equals(propertyName)) {
+ return true;
+ }
+ Boolean b = wtpDataModel.isEnabled(propertyName);
+ return b != null ? b.booleanValue() : true;
+ }
+
+ public IStatus validate(String name) {
+ if (WRAPPED_WTP_DATA_MODEL.equals(name)) {
+ return OK_STATUS;
+ }
+ return wtpDataModel.validateProperty(name);
+ }
+
+ public List getExtendedContext() {
+ return (List) wtpDataModel.getProperty(WTPOperationDataModel.EXTENDED_CONTEXT);
+ }
+
+ public IDataModelOperation getDefaultOperation() {
+ final WTPOperation wtpOperation = wtpDataModel.getDefaultOperation();
+ IDataModelOperation op = new AbstractDataModelOperation() {
+ public ISchedulingRule getSchedulingRule() {
+ return wtpOperation.getSchedulingRule();
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ try {
+ wtpOperation.run(monitor);
+ } catch (InvocationTargetException e) {
+ Logger.getLogger().logError(e);
+ throw new ExecutionException(e.getMessage(), e);
+ } catch (InterruptedException e) {
+ Logger.getLogger().logError(e);
+ throw new ExecutionException(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+ };
+
+ op.setID(getID());
+ return op;
+ }
+
+
+ protected DataModelPropertyDescriptor convert(WTPPropertyDescriptor wtpDescriptor) {
+ return new DataModelPropertyDescriptor(wtpDescriptor.getPropertyValue(), wtpDescriptor.getPropertyDescription());
+ }
+
+ protected DataModelPropertyDescriptor[] convert(WTPPropertyDescriptor[] wtpDescriptors) {
+ DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[wtpDescriptors.length];
+ for (int i = 0; i < descriptors.length; i++) {
+ descriptors[i] = convert(wtpDescriptors[i]);
+ }
+ return descriptors;
+ }
+
+ public void dispose() {
+ wtpDataModel.dispose();
+ super.dispose();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/WTPOperationDataModel.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/WTPOperationDataModel.java
index ae829e9..ee59ae6 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/WTPOperationDataModel.java
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/WTPOperationDataModel.java
@@ -24,10 +24,11 @@
import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler;
/**
- * replace with {@link org.eclipse.wst.common.frameworks.datamodel.IDataModel} and {@link org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider}
- * WTPOperationDataModel is an essential piece of both the WTP Operation and WTP Wizard frameworks.
- * WTPOPerationDataModels (DataModels) act as smart property containers used to pass various
- * properties between components. DataModels are smart property containers because they can:
+ * replace with {@link org.eclipse.wst.common.frameworks.datamodel.IDataModel} and
+ * {@link org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider} WTPOperationDataModel is
+ * an essential piece of both the WTP Operation and WTP Wizard frameworks. WTPOPerationDataModels
+ * (DataModels) act as smart property containers used to pass various properties between components.
+ * DataModels are smart property containers because they can:
* <UL>
* <LI>Compute default values for their properties thus saving clients from needing to populate (or
* understand) all available properties.</LI>
@@ -123,7 +124,7 @@
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 String NESTED_MODEL_DUPLICATE = WTPResourceHandler.getString("33"); //$NON-NLS-1$
-
+
private static final WTPPropertyDescriptor[] NO_DESCRIPTORS = new WTPPropertyDescriptor[0];
private Set validProperties = new HashSet();
@@ -421,8 +422,8 @@
checkValidPropertyName(propertyName);
if (isBaseProperty(propertyName)) {
WTPPropertyDescriptor[] descriptors = doGetValidPropertyDescriptors(propertyName);
- if(null == descriptors){
- descriptors = NO_DESCRIPTORS;
+ if (null == descriptors) {
+ descriptors = NO_DESCRIPTORS;
}
return descriptors;
} else if (nestedModels != null) {
@@ -1145,4 +1146,8 @@
public IProject getTargetProject() {
return null;
}
+
+ public Set getValidProperties() {
+ return Collections.unmodifiableSet(validProperties);
+ }
}
\ No newline at end of file