Author: DartPeng
Date: 2008-09-05 06:32:24 -0400 (Fri, 05 Sep 2008)
New Revision: 10098
Added:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DataTypeID.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ISourceModelAnalyzer.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ITargetModelAnalyzer.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
Removed:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/schema/analyzer.exsd
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/MappingModel.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/ConnectionPropertySection.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalEditor.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/SmooksExtensionPointConstants.java
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/plugin.xml
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java
Log:
1.check some bugs
2.Add property value into the connection model
3.save/load property value with smooks configuration file
Modified: workspace/dart/plugins/org.jboss.tools.smooks.ui/schema/analyzer.exsd
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.ui/schema/analyzer.exsd 2008-09-05
05:33:13 UTC (rev 10097)
+++ workspace/dart/plugins/org.jboss.tools.smooks.ui/schema/analyzer.exsd 2008-09-05
10:32:24 UTC (rev 10098)
@@ -13,7 +13,9 @@
<element name="extension">
<complexType>
<sequence minOccurs="0" maxOccurs="unbounded">
- <element ref="analyzer"/>
+ <element ref="mappingAnalyzer"/>
+ <element ref="sourceModelAnalyzer"/>
+ <element ref="targetModelAnalyzer"/>
</sequence>
<attribute name="point" type="string"
use="required">
<annotation>
@@ -42,7 +44,7 @@
</complexType>
</element>
- <element name="analyzer">
+ <element name="mappingAnalyzer">
<complexType>
<sequence minOccurs="0" maxOccurs="unbounded">
<element ref="targetSourceType"/>
@@ -93,6 +95,78 @@
</complexType>
</element>
+ <element name="sourceModelAnalyzer">
+ <complexType>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="typeID" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="level" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="targetModelAnalyzer">
+ <complexType>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="typeID" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="level" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appInfo>
<meta.section type="since"/>
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -34,7 +34,7 @@
* @author Dart Peng
* @Date Aug 20, 2008
*/
-public abstract class AbstractAnalyzer implements IAnalyzer {
+public abstract class AbstractAnalyzer implements IMappingAnalyzer {
protected List usedConnectionList = new ArrayList();
protected AdapterFactoryEditingDomain editingDomain;
protected ComposedAdapterFactory adapterFactory;
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -11,6 +11,7 @@
package org.jboss.tools.smooks.analyzer;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -30,56 +31,136 @@
public class AnalyzerFactory {
protected static AnalyzerFactory instance = null;
- private Map<String, AnalyzerMapper> analyzerMap = null;
+ private Map<String, MappingAnalyzerMapper> mappingAnalyzerMap = null;
+ private Map<String, ModelAnalyzer> sourceModelAnalyzer = null;
+ private Map<String, ModelAnalyzer> targetModelAnalyzer = null;
+ protected List getIDList(Map<String, ModelAnalyzer> map) {
+ if (map != null) {
+ List<DataTypeID> list = new ArrayList<DataTypeID>();
+ Iterator it = map.keySet().iterator();
+ while (it.hasNext()) {
+ String id = (String) it.next();
+ DataTypeID ti = new DataTypeID();
+ ti.setId(id);
+ ModelAnalyzer analyzer = ((ModelAnalyzer) map.get(id));
+ if(analyzer == null) continue;
+ ti.setName(analyzer.getName());
+ list.add(ti);
+ }
+ return list;
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ public List getRegistryTargetIDList() {
+ return getIDList(sourceModelAnalyzer);
+ }
+
+ public List getRegistrySourceIDList() {
+ return getIDList(targetModelAnalyzer);
+ }
+
protected AnalyzerFactory() {
- initAnalyzerMap();
+ mappingAnalyzerMap = new HashMap<String, MappingAnalyzerMapper>();
+ sourceModelAnalyzer = new HashMap<String, ModelAnalyzer>();
+ targetModelAnalyzer = new HashMap<String, ModelAnalyzer>();
+ initMappingAnalyzerMap();
+ initModelAnalyzerMap(
+ sourceModelAnalyzer,
+ SmooksExtensionPointConstants.EXTENTION_POINT_ELEMENT_SOURCEMODEL_ANALYZER);
+ initModelAnalyzerMap(
+ targetModelAnalyzer,
+ SmooksExtensionPointConstants.EXTENTION_POINT_ELEMENT_TARGETMODEL_ANALYZER);
}
- private void initAnalyzerMap() {
- if (analyzerMap == null) {
- analyzerMap = new HashMap<String, AnalyzerMapper>();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint ep = registry
- .getExtensionPoint(SmooksExtensionPointConstants.EXTENTION_POINT_ANALYZER);
- if (ep == null)
- return;
- IConfigurationElement[] elements = ep.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- String aname = element
- .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_NAME);
- String clazz = element
- .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_CLASS);
- String typeID = element
- .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_TYPE_ID);
- if (typeID == null || "".equals(typeID))
+ private void initModelAnalyzerMap(Map<String, ModelAnalyzer> map,
+ String elementName) {
+ if (map == null)
+ return;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint ep =
registry.getExtensionPoint(SmooksExtensionPointConstants.EXTENTION_POINT_ANALYZER);
+ if (ep == null)
+ return;
+ IConfigurationElement[] elements = ep.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ if(!element.getName().equals(elementName)) continue;
+ String aname = element
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_NAME);
+ String clazz = element
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_CLASS);
+ String typeID = element
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_TYPE_ID);
+ String level = element
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_LEVEL);
+ ModelAnalyzer analyzer = new ModelAnalyzer();
+ analyzer.setName(aname);
+ analyzer.setTypeID(typeID);
+ analyzer.setAnalyzer(element);
+ int l = -1;
+ try {
+ l = Integer.parseInt(level);
+ } catch (Exception e) {// ingnor
+ }
+ if (typeID == null || "".equals(typeID))
+ continue;
+ if (clazz == null || "".equals(clazz))
+ continue;
+ if (map.get(typeID) != null) {
+ if (l == 0) {
+ map.put(typeID, analyzer);
continue;
- if (clazz == null || "".equals(clazz))
- continue;
+ }
+ } else {
+ map.put(typeID, analyzer);
+ }
+ }
+ }
- AnalyzerMapper mapper = new AnalyzerMapper();
- mapper.setElement(element);
- mapper.setAnalyzerName(aname);
- mapper.setSourceDataTypeID(typeID);
+ private void initMappingAnalyzerMap() {
- IConfigurationElement[] childrenElements = element
- .getChildren();
- for (int j = 0; j < childrenElements.length; j++) {
- IConfigurationElement childElement = childrenElements[j];
- if (childElement
- .getName()
- .equals(
- SmooksExtensionPointConstants.EXTENTION_POINT_ELEMENT_TARGETSOURCETYPE)) {
- String tid = childElement
- .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_ID);
- if (tid == null || "".equals(tid))
- continue;
- mapper.addTargetDataTypeID(tid);
- }
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint ep = registry
+ .getExtensionPoint(SmooksExtensionPointConstants.EXTENTION_POINT_ANALYZER);
+ if (ep == null)
+ return;
+ IConfigurationElement[] elements = ep.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+
+ IConfigurationElement element = elements[i];
+ if(!element.getName().equals(SmooksExtensionPointConstants.EXTENTION_POINT_ELEMENT_MAPPINGANALYZER))
continue;
+ String aname = element
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_NAME);
+ String clazz = element
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_CLASS);
+ String typeID = element
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_TYPE_ID);
+ if (typeID == null || "".equals(typeID))
+ continue;
+ if (clazz == null || "".equals(clazz))
+ continue;
+
+ MappingAnalyzerMapper mapper = new MappingAnalyzerMapper();
+ mapper.setElement(element);
+ mapper.setAnalyzerName(aname);
+ mapper.setSourceDataTypeID(typeID);
+
+ IConfigurationElement[] childrenElements = element.getChildren();
+ for (int j = 0; j < childrenElements.length; j++) {
+ IConfigurationElement childElement = childrenElements[j];
+ if (childElement
+ .getName()
+ .equals(
+ SmooksExtensionPointConstants.EXTENTION_POINT_ELEMENT_TARGETSOURCETYPE)) {
+ String tid = childElement
+ .getAttribute(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_ID);
+ if (tid == null || "".equals(tid))
+ continue;
+ mapper.addTargetDataTypeID(tid);
}
- analyzerMap.put(typeID, mapper);
}
+ mappingAnalyzerMap.put(typeID, mapper);
}
}
@@ -93,36 +174,90 @@
return instance;
}
- public IAnalyzer getGraphModelAnalyzer(String sourceDataTypeID,
+ public IMappingAnalyzer getMappingAnalyzer(String sourceDataTypeID,
String targetDataTypeID) throws CoreException {
- if (this.analyzerMap != null) {
- AnalyzerMapper mapper = (AnalyzerMapper) this.analyzerMap
+ if (this.mappingAnalyzerMap != null) {
+ MappingAnalyzerMapper mapper = (MappingAnalyzerMapper) this.mappingAnalyzerMap
.get(sourceDataTypeID);
if (mapper == null)
return null;
if (mapper.canTransformToTheTarget(targetDataTypeID)) {
- return (IAnalyzer) createAnalyzer(mapper);
+ return (IMappingAnalyzer) createAnalyzer(mapper);
}
}
return null;
}
- public IAnalyzer getSmooksModelAnalyzer(String datatypeID)
+ public ISourceModelAnalyzer getSourceModelAnalyzer(String datatypeID)
throws CoreException {
- if (this.analyzerMap != null) {
- AnalyzerMapper mapper = (AnalyzerMapper) this.analyzerMap
+ if (this.sourceModelAnalyzer != null) {
+ ModelAnalyzer mapper = (ModelAnalyzer) this.sourceModelAnalyzer
.get(datatypeID);
- return (IAnalyzer) createAnalyzer(mapper);
+ if(mapper == null) return null;
+ return (ISourceModelAnalyzer) createModelAnalyzer(mapper);
}
return null;
}
- protected Object createAnalyzer(AnalyzerMapper mapper) throws CoreException {
+ public ITargetModelAnalyzer getTargetModelAnalyzer(String datatypeID)
+ throws CoreException {
+ if (this.targetModelAnalyzer != null) {
+ ModelAnalyzer mapper = (ModelAnalyzer) this.targetModelAnalyzer
+ .get(datatypeID);
+ if(mapper == null) return null;
+ return (ITargetModelAnalyzer) createModelAnalyzer(mapper);
+ }
+ return null;
+ }
+
+ protected Object createModelAnalyzer(ModelAnalyzer analyzer)
+ throws CoreException {
+ IConfigurationElement element = analyzer.getAnalyzer();
+ if (element != null) {
+ return element
+ .createExecutableExtension(SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_CLASS);
+ }
+ return null;
+ }
+
+ protected Object createAnalyzer(MappingAnalyzerMapper mapper)
+ throws CoreException {
return mapper.getElement().createExecutableExtension(
SmooksExtensionPointConstants.EXTENTION_POINT_ATTRIBUTE_CLASS);
}
- private class AnalyzerMapper {
+ private class ModelAnalyzer {
+ private IConfigurationElement analyzer;
+ private String typeID;
+ private String name;
+
+ public IConfigurationElement getAnalyzer() {
+ return analyzer;
+ }
+
+ public void setAnalyzer(IConfigurationElement analyzer) {
+ this.analyzer = analyzer;
+ }
+
+ public String getTypeID() {
+ return typeID;
+ }
+
+ public void setTypeID(String typeID) {
+ this.typeID = typeID;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ }
+
+ private class MappingAnalyzerMapper {
String sourceDataTypeID = null;
IConfigurationElement element;
String analyzerName = null;
Added:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DataTypeID.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DataTypeID.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DataTypeID.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.analyzer;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 5, 2008
+ */
+public class DataTypeID {
+ private String name;
+ private String id;
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DataTypeID.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.smooks.analyzer;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.jboss.tools.smooks.graphical.GraphInformations;
-import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
-import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
-import org.milyn.xsd.smooks.SmooksResourceListType;
-
-/**
- * @author Dart Peng
- *
- */
-public interface IAnalyzer {
- public void analyzeMappingGraphModel(
- SmooksConfigurationFileGenerateContext context)
- throws SmooksAnalyzerException;
-
- public List<MappingModel> analyzeMappingSmooksModel(
- SmooksResourceListType listType,Object sourceObject,Object targetObject);
-
- public Object buildSourceInputObjects(GraphInformations graphInfo,
- SmooksResourceListType listType, IFile sourceFile)
- throws InvocationTargetException;
-
- public Object buildTargetInputObjects(GraphInformations graphInfo,
- SmooksResourceListType listType, IFile sourceFile)
- throws InvocationTargetException;
-}
Copied:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java
(from rev 10056,
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java)
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.analyzer;
+
+import java.util.List;
+
+import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+import org.milyn.xsd.smooks.SmooksResourceListType;
+
+/**
+ * @author Dart Peng
+ *
+ */
+public interface IMappingAnalyzer {
+ public void analyzeMappingGraphModel(
+ SmooksConfigurationFileGenerateContext context)
+ throws SmooksAnalyzerException;
+ public List<MappingModel> analyzeMappingSmooksModel(
+ SmooksResourceListType listType,Object sourceObject,Object targetObject);
+
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ISourceModelAnalyzer.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ISourceModelAnalyzer.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ISourceModelAnalyzer.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.analyzer;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.milyn.xsd.smooks.SmooksResourceListType;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 5, 2008
+ */
+public interface ISourceModelAnalyzer {
+ public Object buildSourceInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException;
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ISourceModelAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ITargetModelAnalyzer.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ITargetModelAnalyzer.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ITargetModelAnalyzer.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.analyzer;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.milyn.xsd.smooks.SmooksResourceListType;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 5, 2008
+ */
+public interface ITargetModelAnalyzer {
+ public Object buildTargetInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException;
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ITargetModelAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/MappingModel.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/MappingModel.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/MappingModel.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -3,6 +3,11 @@
*/
package org.jboss.tools.smooks.analyzer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.smooks.ui.gef.model.PropertyModel;
+
/**
* @author root
*
@@ -11,6 +16,8 @@
protected Object source;
protected Object target;
+ protected List<PropertyModel> properties = new ArrayList<PropertyModel>();
+
public MappingModel(Object source,Object target){
setSource(source);
setTarget(target);
@@ -42,4 +49,12 @@
buffer.append(";Target is NULL ");
return buffer.toString();
}
+
+ public List<PropertyModel> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List<PropertyModel> properties) {
+ this.properties = properties;
+ }
}
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -26,7 +26,7 @@
IProgressMonitor monitor) throws SmooksAnalyzerException,
IOException, CoreException {
AnalyzerFactory factory = AnalyzerFactory.getInstance();
- IAnalyzer analyzer = factory.getGraphModelAnalyzer(context.getSourceDataTypeID(),
+ IMappingAnalyzer analyzer = factory.getMappingAnalyzer(context.getSourceDataTypeID(),
context.getTargetDataTypeID());
if (analyzer == null)
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/ConnectionPropertySection.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/ConnectionPropertySection.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/ConnectionPropertySection.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -3,6 +3,8 @@
*/
package org.jboss.tools.smooks.ui;
+import java.util.Iterator;
+
import org.eclipse.gef.EditPart;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CellLabelProvider;
@@ -19,6 +21,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
@@ -26,6 +29,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
@@ -65,7 +69,8 @@
mainComposite.setLayout(gridLayout);
tableViewer = new TableViewer(mainComposite);
tableViewer.setColumnProperties(new String[] { "name", "value" });
- tableViewer.setCellEditors(new CellEditor[] { new
TextCellEditor(tableViewer.getTable()),
+ tableViewer.setCellEditors(new CellEditor[] {
+ new TextCellEditor(tableViewer.getTable()),
new TextCellEditor(tableViewer.getTable()) });
tableViewer.setCellModifier(new ICellModifier() {
@@ -84,9 +89,21 @@
return element;
}
- public void modify(Object element, String property, Object value) {
- // TODO Auto-generated method stub
+ public void modify(Object item, String property, Object value) {
+ Object element = null;
+ if (item instanceof TableItem) {
+ element = ((TableItem) item).getData();
+ }
+ if (element instanceof PropertyModel && value instanceof String) {
+ if (property.equals("name")) {
+ ((PropertyModel) element).setName((String) value);
+ }
+ if (property.equals("value")) {
+ ((PropertyModel) element).setValue((String) value);
+ }
+ refresh();
+ }
}
});
@@ -96,7 +113,7 @@
public Object[] getElements(Object inputElement) {
if (inputElement instanceof AbstractStructuredDataConnectionModel) {
return ((AbstractStructuredDataConnectionModel) inputElement)
- .getProperties().toArray();
+ .getPropertyArray();
}
return new Object[] {};
}
@@ -174,7 +191,7 @@
Object m = ((EditPart) editPart).getModel();
if (m instanceof AbstractStructuredDataConnectionModel) {
((AbstractStructuredDataConnectionModel) m)
- .getProperties().add(model);
+ .addPropertyModel(model);
refresh();
StructuredSelection selection = new StructuredSelection(
model);
@@ -191,7 +208,30 @@
SWT.NONE);
gd = new GridData(GridData.FILL_VERTICAL);
button2.setLayoutData(gd);
+ button2.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+
+ Object editPart = ((IStructuredSelection) getSelection())
+ .getFirstElement();
+ if (editPart instanceof EditPart) {
+ Object m = ((EditPart) editPart).getModel();
+ if (m instanceof AbstractStructuredDataConnectionModel) {
+ IStructuredSelection selection = (IStructuredSelection) tableViewer
+ .getSelection();
+ Iterator it = selection.iterator();
+ while (it.hasNext()) {
+ PropertyModel model = (PropertyModel) it.next();
+ ((AbstractStructuredDataConnectionModel) m)
+ .removePropertyModel(model);
+ }
+ refresh();
+ }
+ }
+ }
+
+ });
// Button button3 = factory.createButton(buttonComposite, "New ",
// SWT.NONE);
// gd = new GridData(GridData.FILL_VERTICAL);
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalEditor.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalEditor.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalEditor.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -40,7 +40,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.jboss.tools.smooks.analyzer.IAnalyzer;
+import org.jboss.tools.smooks.analyzer.IMappingAnalyzer;
import org.jboss.tools.smooks.ui.gef.editparts.SmooksEditPartFactory;
import org.jboss.tools.smooks.ui.gef.model.RootModel;
import org.jboss.tools.smooks.ui.modelparser.ParseEngine;
@@ -189,7 +189,7 @@
@Override
public void doSave(IProgressMonitor monitor) {
monitor.beginTask("Saving...", -1);
- IAnalyzer analyzer = null;
+ IMappingAnalyzer analyzer = null;
// TODO TEST
if(true) return;
// JavaBeanAnalyzer analyzer = new JavaBeanAnalyzer();
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -12,7 +12,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EventObject;
@@ -24,6 +23,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.draw2d.ConnectionLayer;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage.Registry;
@@ -50,6 +50,7 @@
import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -57,6 +58,7 @@
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSourceAdapter;
@@ -88,9 +90,10 @@
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.jboss.tools.smooks.analyzer.AnalyzerFactory;
-import org.jboss.tools.smooks.analyzer.IAnalyzer;
+import org.jboss.tools.smooks.analyzer.IMappingAnalyzer;
+import org.jboss.tools.smooks.analyzer.ISourceModelAnalyzer;
+import org.jboss.tools.smooks.analyzer.ITargetModelAnalyzer;
import org.jboss.tools.smooks.analyzer.MappingModel;
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.analyzer.SmooksFileBuilder;
@@ -194,6 +197,16 @@
@Override
protected void createFormContent(IManagedForm managedForm) {
+
+ try {
+ this.initTansformViewerModel((IEditorSite) getSite(),
+ getEditorInput());
+ } catch (Throwable e) {
+ Status status = UIUtils.createErrorStatus(e);
+ ErrorDialog.openError(getSite().getShell(), "Error", "error",
+ status);
+ }
+
final ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
@@ -347,7 +360,7 @@
this.hookGraphicalViewer();
this.initGraphicalViewer();
- getSite().setSelectionProvider(this);
+ // getSite().setSelectionProvider(this);
}
protected SmooksFileBuilder createSmooksFileBulder() {
@@ -389,6 +402,8 @@
}
protected void expandConnectionModel(TreeViewer viewer, boolean isSource) {
+ if (initConnectionList == null || initConnectionList.isEmpty())
+ return;
ITreeContentProvider provider = (ITreeContentProvider) viewer
.getContentProvider();
if (provider == null)
@@ -566,6 +581,7 @@
protected void hookGraphicalViewer() {
getSelectionSynchronizer().addViewer(getGraphicalViewer());
this.getGraphicalViewer().addSelectionChangedListener(this);
+ getSite().setSelectionProvider(getGraphicalViewer());
getGraphicalViewer().addDropTargetListener(
new MappingPanelDropTargetListener(this.getGraphicalViewer()));
}
@@ -627,8 +643,11 @@
TreeItemRelationModel target = (TreeItemRelationModel) iterator2
.next();
if (target instanceof TargetModel) {
- if (canConnected(source, target)) {
- new LineConnectionModel(source, target);
+ MappingModel mapping = getMappingModel(source, target);
+ if (mapping != null) {
+ LineConnectionModel connection = new LineConnectionModel(
+ source, target);
+ connection.setProperties(mapping.getProperties());
}
}
}
@@ -636,21 +655,21 @@
}
}
- protected boolean canConnected(TreeItemRelationModel source,
+ protected MappingModel getMappingModel(TreeItemRelationModel source,
TreeItemRelationModel target) {
Object sourceReferModel = source.getReferenceEntityModel();
Object targetReferModel = target.getReferenceEntityModel();
if (initConnectionList == null)
- return false;
+ return null;
for (Iterator iterator = initConnectionList.iterator(); iterator
.hasNext();) {
MappingModel mapping = (MappingModel) iterator.next();
Object s = mapping.getSource();
Object t = mapping.getTarget();
if (s == sourceReferModel && t == targetReferModel)
- return true;
+ return mapping;
}
- return false;
+ return null;
}
public SelectionSynchronizer getSelectionSynchronizer() {
@@ -697,6 +716,58 @@
this.targetViewerInitor = targetViewerInitor;
}
+ protected void initTansformViewerModel(IEditorSite site, IEditorInput input)
+ throws Throwable {
+ graphicalInformationSaver = new GraphicalInformationSaver(input);
+
+ GraphInformations graph = null;
+ try {
+ graph = graphicalInformationSaver.doLoad();
+ initFormEditorWithGraphInfo(graph);
+ } catch (Throwable t) {
+
+ }
+
+ if (sourceDataTypeID == null || targetDataTypeID == null) {
+ TypeIDSelectionWizard wizard = new TypeIDSelectionWizard();
+ wizard.setSourceDataTypeID(sourceDataTypeID);
+ wizard.setTargetDataTypeID(targetDataTypeID);
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+ if (dialog.open() == org.eclipse.jface.dialogs.Dialog.OK) {
+ sourceDataTypeID = wizard.getSourceDataTypeID();
+ targetDataTypeID = wizard.getTargetDataTypeID();
+ }
+ }
+ String path = ResourcesPlugin.getWorkspace().getRoot().getLocation()
+ .append(((IFileEditorInput) input).getFile().getFullPath())
+ .toString();
+ Resource resource = new SmooksResourceFactoryImpl().createResource(URI
+ .createFileURI(path));
+ resource.load(Collections.EMPTY_MAP);
+ ISourceModelAnalyzer sourceModelAnalyzer = AnalyzerFactory
+ .getInstance().getSourceModelAnalyzer(sourceDataTypeID);
+ ITargetModelAnalyzer targetModelAnalyzer = AnalyzerFactory
+ .getInstance().getTargetModelAnalyzer(targetDataTypeID);
+ IMappingAnalyzer connectionAnalyzer = AnalyzerFactory.getInstance()
+ .getMappingAnalyzer(sourceDataTypeID, targetDataTypeID);
+ SmooksResourceListType listType = ((DocumentRoot) resource
+ .getContents().get(0)).getSmooksResourceList();
+ if (sourceModelAnalyzer != null)
+ sourceTreeViewerInputModel = sourceModelAnalyzer
+ .buildSourceInputObjects(graph, listType,
+ ((IFileEditorInput) input).getFile());
+ if (targetModelAnalyzer != null)
+ targetTreeViewerInputModel = targetModelAnalyzer
+ .buildTargetInputObjects(graph, listType,
+ ((IFileEditorInput) input).getFile());
+ if (connectionAnalyzer != null) {
+ initConnectionList = connectionAnalyzer.analyzeMappingSmooksModel(
+ listType, sourceTreeViewerInputModel,
+ targetTreeViewerInputModel);
+ }
+
+ }
+
/*
* (non-Javadoc)
*
@@ -705,50 +776,10 @@
*/
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
+ // if (Registry.INSTANCE.get(GraphicalPackage.eNS_URI) == null) {
Registry.INSTANCE.put(GraphicalPackage.eNS_URI,
GraphicalPackage.eINSTANCE);
- graphicalInformationSaver = new GraphicalInformationSaver(input);
- try {
- GraphInformations graph = graphicalInformationSaver.doLoad();
- initFormEditorWithGraphInfo(graph);
-
- String path = ResourcesPlugin.getWorkspace().getRoot()
- .getLocation().append(
- ((IFileEditorInput) input).getFile().getFullPath())
- .toString();
- Resource resource = new SmooksResourceFactoryImpl()
- .createResource(URI.createFileURI(path));
- resource.load(Collections.EMPTY_MAP);
- IAnalyzer sourceModelAnalyzer = AnalyzerFactory.getInstance()
- .getSmooksModelAnalyzer(sourceDataTypeID);
- IAnalyzer targetModelAnalyzer = AnalyzerFactory.getInstance()
- .getSmooksModelAnalyzer(targetDataTypeID);
- IAnalyzer connectionAnalyzer = AnalyzerFactory.getInstance()
- .getGraphModelAnalyzer(sourceDataTypeID, targetDataTypeID);
- SmooksResourceListType listType = ((DocumentRoot) resource
- .getContents().get(0)).getSmooksResourceList();
- if (sourceModelAnalyzer != null)
- sourceTreeViewerInputModel = sourceModelAnalyzer
- .buildSourceInputObjects(graph, listType,
- ((IFileEditorInput) input).getFile());
- if (targetModelAnalyzer != null)
- targetTreeViewerInputModel = targetModelAnalyzer
- .buildTargetInputObjects(graph, listType,
- ((IFileEditorInput) input).getFile());
- if (connectionAnalyzer != null) {
- initConnectionList = connectionAnalyzer
- .analyzeMappingSmooksModel(listType,
- sourceTreeViewerInputModel,
- targetTreeViewerInputModel);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- } catch (CoreException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
+ // }
}
protected void initFormEditorWithGraphInfo(GraphInformations graph) {
@@ -757,6 +788,9 @@
this.sourceDataTypeID = mapping.getSourceTypeID();
this.targetDataTypeID = mapping.getTargetTypeID();
}
+ if (sourceDataTypeID == null || targetDataTypeID == null) {
+
+ }
}
/**
@@ -937,7 +971,7 @@
public void selectionChanged(SelectionChangedEvent event) {
updateSelectionActions();
- this.setSelection(event.getSelection());
+ // this.setSelection(event.getSelection());
}
protected void updateSelectionActions() {
Added:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.editors;
+
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 5, 2008
+ */
+public class TypeIDSelectionWizard extends Wizard {
+ private String sourceDataTypeID = null;
+ private String targetDataTypeID = null;
+ private TypeIDSelectionWizardPage page = null;
+ public String getSourceDataTypeID() {
+ return sourceDataTypeID;
+ }
+ public void setSourceDataTypeID(String sourceDataTypeID) {
+ this.sourceDataTypeID = sourceDataTypeID;
+ }
+ public String getTargetDataTypeID() {
+ return targetDataTypeID;
+ }
+ public void setTargetDataTypeID(String targetDataTypeID) {
+ this.targetDataTypeID = targetDataTypeID;
+ }
+
+ public void addPages(){
+ if(page == null){
+ page = new TypeIDSelectionWizardPage("TypeID Selection");
+ this.addPage(page);
+ }
+ super.addPages();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ String sid = page.getSourceDataTypeID();
+ String tid = page.getTargetDataTypeID();
+ if(sid == null || tid == null) return false;
+ this.sourceDataTypeID = sid;
+ this.targetDataTypeID = tid;
+ return true;
+ }
+
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.editors;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.tools.smooks.analyzer.AnalyzerFactory;
+import org.jboss.tools.smooks.analyzer.DataTypeID;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 5, 2008
+ */
+public class TypeIDSelectionWizardPage extends WizardPage {
+
+ protected CheckboxTableViewer source;
+ protected CheckboxTableViewer target;
+
+ public TypeIDSelectionWizardPage(String pageName, String title,
+ ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ public TypeIDSelectionWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ gl.makeColumnsEqualWidth = true;
+ mainComposite.setLayout(gl);
+ List<DataTypeID> sourceList = AnalyzerFactory.getInstance()
+ .getRegistrySourceIDList();
+ List<DataTypeID> targetList = AnalyzerFactory.getInstance()
+ .getRegistryTargetIDList();
+ Label sl = new Label(mainComposite, SWT.NONE);
+ sl.setText("Source Data Type ID List : ");
+
+ Label tl = new Label(mainComposite, SWT.NONE);
+ tl.setText("Target Data Type ID List : ");
+
+ source = createTableViewer(mainComposite);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ source.getTable().setLayoutData(gd);
+ target = createTableViewer(mainComposite);
+ target.getTable().setLayoutData(gd);
+
+ source.setInput(sourceList);
+ target.setInput(targetList);
+ initViewer();
+
+ this.setControl(mainComposite);
+ }
+
+ public String getSourceDataTypeID() {
+ return getDataTypeID(source);
+ }
+
+ public String getTargetDataTypeID() {
+ return getDataTypeID(target);
+ }
+
+ protected String getDataTypeID(CheckboxTableViewer viewer) {
+ Object[] objs = viewer.getCheckedElements();
+ if (objs == null)
+ return null;
+ if (objs.length > 1)
+ return null;
+ DataTypeID d = (DataTypeID) objs[0];
+ return d.getId();
+ }
+
+ protected void initViewer() {
+ IWizard wizard = this.getWizard();
+ if (wizard instanceof TypeIDSelectionWizard) {
+ String s = ((TypeIDSelectionWizard) wizard).getSourceDataTypeID();
+ String t = ((TypeIDSelectionWizard) wizard).getTargetDataTypeID();
+ if (initViewerCheckState(s, source)) {
+ source.getTable().setEnabled(false);
+ }
+ if (initViewerCheckState(t, target)) {
+ target.getTable().setEnabled(false);
+ }
+ }
+ }
+
+ protected boolean initViewerCheckState(String id, CheckboxTableViewer viewer) {
+ if(id == null) return false;
+ List l = (List) viewer.getInput();
+ for (Iterator iterator = l.iterator(); iterator.hasNext();) {
+ DataTypeID dti = (DataTypeID) iterator.next();
+ if (id.equals(dti.getId())) {
+ viewer.setChecked(dti, true);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected CheckboxTableViewer createTableViewer(Composite parent) {
+ final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(
+ parent, SWT.FULL_SELECTION);
+ viewer.addCheckStateListener(new ICheckStateListener() {
+ private boolean fireEvent = true;
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (!fireEvent)
+ return;
+ boolean check = event.getChecked();
+ if (check) {
+ fireEvent = false;
+ viewer.setAllChecked(false);
+ viewer.setChecked(event.getElement(), true);
+ fireEvent = true;
+ }
+ }
+
+ });
+ TableColumn nameColumn = new TableColumn(viewer.getTable(), SWT.NONE);
+ nameColumn.setWidth(100);
+ nameColumn.setText("Name");
+ TableColumn idColumn = new TableColumn(viewer.getTable(), SWT.NONE);
+ idColumn.setWidth(100);
+ idColumn.setText("ID");
+ viewer.setContentProvider(new TypeIDContentProvider());
+ viewer.setLabelProvider(new TypeIDLabelProvider());
+ return viewer;
+ }
+
+ private class TypeIDContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List) inputElement).toArray();
+ }
+ return new Object[] {};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ }
+
+ private class TypeIDLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof DataTypeID) {
+ switch (columnIndex) {
+ case 0:
+ return ((DataTypeID) element).getName();
+ case 1:
+ return ((DataTypeID) element).getId();
+ }
+ }
+ return "";
+ }
+
+ }
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -1,5 +1,8 @@
package org.jboss.tools.smooks.ui.gef.editparts;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.ConnectionLocator;
import org.eclipse.draw2d.Figure;
@@ -15,6 +18,7 @@
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.jboss.tools.smooks.ui.gef.figures.CurveLineConnection;
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataConnectionModel;
import org.jboss.tools.smooks.ui.gef.model.IConnectableModel;
import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
import org.jboss.tools.smooks.ui.gef.model.TreeItemRelationModel;
@@ -22,12 +26,30 @@
import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
public class StructuredDataConnectionEditPart extends
- AbstractConnectionEditPart {
+ AbstractConnectionEditPart implements PropertyChangeListener{
public StructuredDataConnectionEditPart() {
super();
}
+
+ public void activate() {
+ super.activate();
+ Object model = getModel();
+ if(model instanceof AbstractStructuredDataConnectionModel){
+ ((AbstractStructuredDataConnectionModel)model).addPropertyChangeListener(this);
+ }
+ }
+ public void deactivate() {
+ Object model = getModel();
+ if(model instanceof AbstractStructuredDataConnectionModel){
+ ((AbstractStructuredDataConnectionModel)model).removePropertyChangeListener(this);
+ }
+ super.deactivate();
+ }
+
+
+
/*
* (non-Javadoc)
*
@@ -187,4 +209,8 @@
changeTreeItemSelectionStatus(true);
}
}
+
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ }
}
\ No newline at end of file
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -1,14 +1,22 @@
package org.jboss.tools.smooks.ui.gef.model;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.List;
-public class AbstractStructuredDataConnectionModel {
+public class AbstractStructuredDataConnectionModel implements PropertyChangeListener {
+ public static final String CONNECTION_PROPERTY_CHANGE =
"__connection_property_change";
protected IConnectableModel source;
protected IConnectableModel target;
protected List<PropertyModel> properties = new ArrayList<PropertyModel>();
+
+ private PropertyChangeSupport support =new PropertyChangeSupport(this);
+
public AbstractStructuredDataConnectionModel(IConnectableModel source,
IConnectableModel target) {
+ this();
this.setSource(source);
this.setTarget(target);
attachSource();
@@ -16,8 +24,15 @@
}
public AbstractStructuredDataConnectionModel(){
-
}
+
+ public void addPropertyChangeListener(PropertyChangeListener listener){
+ support.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener){
+ support.removePropertyChangeListener(listener);
+ }
/**
* t�ӵ���ʼ����ӵ�source
@@ -60,12 +75,35 @@
public void setTarget(IConnectableModel target) {
this.target = target;
}
+
+ public Object[] getPropertyArray(){
+ return properties.toArray();
+ }
- public List<PropertyModel> getProperties() {
+ protected List<PropertyModel> getProperties() {
return properties;
}
public void setProperties(List<PropertyModel> properties) {
this.properties = properties;
}
+
+ public void addPropertyModel(PropertyModel property){
+ this.getProperties().add(property);
+ property.addPropertyChangeListener(this);
+ support.firePropertyChange(CONNECTION_PROPERTY_CHANGE, null, property);
+ }
+
+ public void removePropertyModel(PropertyModel property){
+ property.removePropertyChangeListener(this);
+ this.getProperties().remove(property);
+ support.firePropertyChange(CONNECTION_PROPERTY_CHANGE, property, null);
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ String name = evt.getPropertyName();
+ if(CONNECTION_PROPERTY_CHANGE.equals(name)){
+ support.firePropertyChange(evt);
+ }
+ }
}
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -23,7 +23,11 @@
}
public void setName(String name) {
+ String oldName = this.name;
this.name = name;
+ firePropertyChange(
+ AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_CHANGE,
+ oldName, this.name);
}
public String getValue() {
@@ -31,6 +35,10 @@
}
public void setValue(String value) {
+ String oldValue = this.value;
this.value = value;
+ firePropertyChange(
+ AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_CHANGE,
+ oldValue, this.value);
}
}
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/SmooksExtensionPointConstants.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/SmooksExtensionPointConstants.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/SmooksExtensionPointConstants.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -22,13 +22,19 @@
public static final String EXTENTION_POINT_ANALYZER =
"org.jboss.tools.smooks.ui.analyzer";
- public static final String EXTENTION_POINT_ELEMENT_ANALYZER = "analyzer";
+ public static final String EXTENTION_POINT_ELEMENT_SOURCEMODEL_ANALYZER =
"sourceModelAnalyzer";
+ public static final String EXTENTION_POINT_ELEMENT_TARGETMODEL_ANALYZER =
"targetModelAnalyzer";
+
+ public static final String EXTENTION_POINT_ELEMENT_MAPPINGANALYZER =
"mappingAnalyzer";
+
public static final String EXTENTION_POINT_ELEMENT_TARGETSOURCETYPE =
"targetSourceType";
public static final String EXTENTION_POINT_ATTRIBUTE_CLASS = "class";
public static final String EXTENTION_POINT_ATTRIBUTE_TYPE_ID = "typeID";
+
+ public static final String EXTENTION_POINT_ATTRIBUTE_LEVEL = "level";
public static final String EXTENTION_POINT_ATTRIBUTE_LABEL_PROVIDER =
"labelProvider";
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -1,21 +1,26 @@
package org.jboss.tools.smooks.utils;
+import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
import org.jboss.tools.smooks.ui.ViewerInitorStore;
import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
import org.jboss.tools.smooks.ui.gef.model.IConnectableModel;
@@ -34,6 +39,21 @@
fill.marginWidth = marginW;
return fill;
}
+
+ public static Status createErrorStatus(Throwable throwable,String message){
+ while(throwable != null && throwable instanceof InvocationTargetException){
+ throwable = ((InvocationTargetException)throwable).getTargetException();
+ }
+ return new Status(Status.ERROR,SmooksUIActivator.PLUGIN_ID,message,throwable);
+ }
+
+ public static void showErrorDialog(Shell shell,Status status){
+ ErrorDialog.openError(shell, "Error", "error", status);
+ }
+
+ public static Status createErrorStatus(Throwable throwable){
+ return createErrorStatus(throwable, "Error");
+ }
public static FillLayout createFormCompositeFillLayout() {
return createFillLayout(1, 1);
Modified: workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/plugin.xml
===================================================================
--- workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/plugin.xml 2008-09-05
05:33:13 UTC (rev 10097)
+++ workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/plugin.xml 2008-09-05
10:32:24 UTC (rev 10098)
@@ -13,7 +13,7 @@
</extension>
<extension
point="org.jboss.tools.smooks.ui.analyzer">
- <analyzer
+ <mappingAnalyzer
class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
name="JavaBean Analyzer"
typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
@@ -21,6 +21,54 @@
id="org.jboss.tools.smooks.ui.viewerInitor.javabean"
name="java2java">
</targetSourceType>
- </analyzer>
+ </mappingAnalyzer>
+ <sourceModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="JavaBean SourceModel Analyzer"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </sourceModelAnalyzer>
+ <targetModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="JavaBean TargetModel Analyzer"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </targetModelAnalyzer>
+ <sourceModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="Javaa12"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.jadavabean">
+ </sourceModelAnalyzer>
+ <sourceModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="421a"
+ typeID="org.jboss.tools.smooks.ui.viea123nitor.javabean">
+ </sourceModelAnalyzer>
+ <sourceModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="yyy"
+ typeID="org.jboss.tools.sm55555555555555555">
+ </sourceModelAnalyzer>
+ <targetModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="zer"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabea1">
+ </targetModelAnalyzer>
+ <targetModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="J512"
+ typeID="org.jb1">
+ </targetModelAnalyzer>
+ <targetModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="55t"
+ typeID="o5114141">
+ </targetModelAnalyzer>
</extension>
</plugin>
Modified:
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
---
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -23,7 +23,10 @@
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -31,7 +34,9 @@
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.jboss.tools.smooks.analyzer.IAnalyzer;
+import org.jboss.tools.smooks.analyzer.IMappingAnalyzer;
+import org.jboss.tools.smooks.analyzer.ISourceModelAnalyzer;
+import org.jboss.tools.smooks.analyzer.ITargetModelAnalyzer;
import org.jboss.tools.smooks.analyzer.MappingModel;
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.graphical.GraphInformations;
@@ -41,6 +46,7 @@
import org.jboss.tools.smooks.ui.gef.model.GraphRootModel;
import org.jboss.tools.smooks.ui.gef.model.IConnectableModel;
import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
+import org.jboss.tools.smooks.ui.gef.model.PropertyModel;
import org.jboss.tools.smooks.ui.gef.model.TreeItemRelationModel;
import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
import org.jboss.tools.smooks.utils.ProjectClassLoader;
@@ -59,7 +65,8 @@
* @author Dart Peng
*
*/
-public class JavaBeanAnalyzer implements IAnalyzer {
+public class JavaBeanAnalyzer implements IMappingAnalyzer,
+ ISourceModelAnalyzer, ITargetModelAnalyzer {
public static final String BEANPOPULATOR =
"org.milyn.javabean.BeanPopulator";
@@ -222,6 +229,7 @@
.createParamType();
bindingsParam.setName("bindings");
resourceConfig.getParam().add(bindingsParam);
+
// to dispatch the target's children (Order processing)
List children = targetJavaBean.getProperties();
@@ -244,6 +252,8 @@
.getModelTargetConnections().get(0);
if (connectionIsUsed(childConnection))
continue;
+ Object[] properties = childConnection
+ .getPropertyArray();
JavaBeanModel jbean = (JavaBeanModel) child
.getReferenceEntityModel();
String currentSelectorName = getSelectorString(
@@ -252,9 +262,20 @@
(AbstractStructuredDataModel) childConnection
.getSource(),
(AbstractStructuredDataModel) source);
- SmooksModelUtils.addBindingTypeToParamType(
- bindingsParam, jbean.getName(),
- currentSelectorName, null, null);
+ AnyType binding = SmooksModelUtils
+ .addBindingTypeToParamType(bindingsParam,
+ jbean.getName(),
+ currentSelectorName, null, null);
+ for (int i = 0; i < properties.length; i++) {
+ PropertyModel property = (PropertyModel) properties[i];
+ String pname = property.getName();
+ String pvalue = property.getValue();
+ binding.getAnyAttribute().add(
+ ExtendedMetaData.INSTANCE
+ .demandFeature(null, pname,
+ false), pvalue);
+ }
+
if (!jbean.isPrimitive()) {
analyzeStructuredDataModel(resourceList, root,
(AbstractStructuredDataModel) child,
@@ -400,6 +421,8 @@
JavaBeanModel target) {
List bindingList = this
.getBindingListFromResourceConfigType(resourceConfig);
+ if (bindingList == null)
+ return;
for (Iterator iterator = bindingList.iterator(); iterator.hasNext();) {
AnyType binding = (AnyType) iterator.next();
String property = SmooksModelUtils.getAttributeValueFromAnyType(
@@ -427,9 +450,22 @@
} else {
sourceModel = findModelWithSelectorString(selector, source);
}
- if(sourceModel != null){
- mappingModelList.add(new MappingModel(sourceModel,
- targetModel));
+ if (sourceModel != null) {
+ MappingModel model = new MappingModel(sourceModel, targetModel);
+ FeatureMap it = binding.getAnyAttribute();
+ for(int i = 0 ; i < it.size() ; i++){
+ EStructuralFeature feature = it.getEStructuralFeature(i);
+ if(feature.equals(SmooksModelUtils.ATTRIBUTE_PROPERTY) ||
+ feature.equals(SmooksModelUtils.ATTRIBUTE_SELECTOR))
+ continue;
+ String pname = feature.getName();
+ String pvalue = it.get(feature, false).toString();
+ PropertyModel pmodel =new PropertyModel();
+ pmodel.setName(pname);
+ pmodel.setValue(pvalue);
+ model.getProperties().add(pmodel);
+ }
+ mappingModelList.add(model);
}
}
}
@@ -588,6 +624,8 @@
ClassLoader classLoader) {
if (currentResourceConfigType != null) {
List bindingList = getBindingListFromResourceConfigType(currentResourceConfigType);
+ if (bindingList == null)
+ return;
for (Iterator iterator = bindingList.iterator(); iterator.hasNext();) {
AnyType binding = (AnyType) iterator.next();
String property = SmooksModelUtils
@@ -652,6 +690,8 @@
if (currentResourceConfigType != null) {
List bindingList = this
.getBindingListFromResourceConfigType(currentResourceConfigType);
+ if (bindingList == null)
+ return;
for (Iterator iterator2 = bindingList.iterator(); iterator2
.hasNext();) {
AnyType binding = (AnyType) iterator2.next();
@@ -717,7 +757,7 @@
model.setError("don't exist");
model.setProperties(new ArrayList());
}
- if(currentModel.getError() != null){
+ if (currentModel.getError() != null) {
currentModel.addProperty(model);
}
buildSourceInputProperties(listType, model, false, true,
Modified:
workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java
===================================================================
---
workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java 2008-09-05
05:33:13 UTC (rev 10097)
+++
workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java 2008-09-05
10:32:24 UTC (rev 10098)
@@ -42,10 +42,11 @@
.demandFeature("http://www.milyn.org/xsd/smooks-1.0.xsd",
"binding", true);
- public static void addBindingTypeToParamType(ParamType param,
+ public static AnyType addBindingTypeToParamType(ParamType param,
String property, String selector, String type, String uri) {
AnyType binding = createBindingType(property, selector, type, uri);
param.getMixed().add(ELEMENT_BINDING, binding);
+ return binding;
}
public static String getParmaText(String paramName,