Author: DartPeng
Date: 2008-09-24 05:01:53 -0400 (Wed, 24 Sep 2008)
New Revision: 10443
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStrucutredDataCreationWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.xml2java/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
Log:
finish the XML2JavaAnalyzer
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IJavaProject;
@@ -31,6 +32,8 @@
JavaBeanConfigWizardPage page = null;
IJavaProject project = null;
Object result = null;
+
+ Properties properties = new Properties();
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
@@ -74,4 +77,8 @@
return JavaBeanActivator.DATA_TYPE_ID_JAVABEAN;
}
+ public Properties getProperties() {
+ return this.properties;
+ }
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStrucutredDataCreationWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStrucutredDataCreationWizard.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStrucutredDataCreationWizard.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.smooks.ui;
+import java.util.Properties;
+
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
@@ -26,4 +28,6 @@
public String getInputDataTypeID();
+ public Properties getProperties();
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -109,6 +109,8 @@
import org.jboss.tools.smooks.graphical.GraphInformations;
import org.jboss.tools.smooks.graphical.GraphicalPackage;
import org.jboss.tools.smooks.graphical.MappingDataType;
+import org.jboss.tools.smooks.graphical.Param;
+import org.jboss.tools.smooks.graphical.Params;
import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
import org.jboss.tools.smooks.model.DocumentRoot;
import org.jboss.tools.smooks.model.ResourceConfigType;
@@ -565,44 +567,44 @@
createGraphModels(items, SourceModel.class);
}
-
- private void disConnectGraphModel(Class clazz,TreeItemRelationModel model){
- if(clazz == SourceModel.class){
+ private void disConnectGraphModel(Class clazz, TreeItemRelationModel model) {
+ if (clazz == SourceModel.class) {
List list = model.getModelSourceConnections();
List temp = new ArrayList(list);
for (Iterator iterator = temp.iterator(); iterator.hasNext();) {
- LineConnectionModel line = (LineConnectionModel) iterator.next();
+ LineConnectionModel line = (LineConnectionModel) iterator
+ .next();
line.disConnect();
}
temp.clear();
}
-
- if(clazz == TargetModel.class){
+
+ if (clazz == TargetModel.class) {
List list = model.getModelTargetConnections();
List temp = new ArrayList(list);
for (Iterator iterator = temp.iterator(); iterator.hasNext();) {
- LineConnectionModel line = (LineConnectionModel) iterator.next();
+ LineConnectionModel line = (LineConnectionModel) iterator
+ .next();
line.disConnect();
}
temp.clear();
}
}
-
+
private void clearExsitingGraphModels(Class<? extends Object> clazz) {
- if(rootModel != null){
+ if (rootModel != null) {
List children = rootModel.getChildren();
List removeList = new ArrayList();
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
- if(object.getClass() == clazz){
+ if (object.getClass() == clazz) {
removeList.add(object);
- disConnectGraphModel(clazz,(TreeItemRelationModel)object);
+ disConnectGraphModel(clazz, (TreeItemRelationModel) object);
}
}
rootModel.removeChildrenList(removeList);
}
}
-
protected void createTargetGraphModels() {
Tree tree = targetViewer.getTree();
@@ -699,7 +701,8 @@
context.setTargetDataTypeID(this.targetDataTypeID);
context.setSmooksType(SmooksModelConstants.SAX);
context.setDataMappingRootModel(this.rootModel);
- context.setSmooksConfigFile(((IFileEditorInput)getEditorInput()).getFile());
+ context.setSmooksConfigFile(((IFileEditorInput) getEditorInput())
+ .getFile());
}
protected Composite createUISectionContainer(Composite parent, int columns) {
@@ -888,6 +891,8 @@
try {
graph = graphicalInformationSaver.doLoad();
initFormEditorWithGraphInfo(graph);
+ initSmooksContext(graph, this
+ .getSmooksConfigurationFileGenerateContext());
} catch (Throwable t) {
// ignore
t.printStackTrace();
@@ -915,6 +920,21 @@
}
}
+ protected void initSmooksContext(GraphInformations graph,
+ SmooksConfigurationFileGenerateContext context) {
+ Params params = graph.getParams();
+ if (params != null) {
+ List list = params.getParam();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ Param p = (Param) iterator.next();
+ String name = p.getName();
+ String value = p.getValue();
+ if (name != null && value != null)
+ context.putProperty(name, value);
+ }
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -959,6 +979,8 @@
if (dialog.open() == WizardDialog.OK) {
IStrucutredDataCreationWizard cw = dialog
.getCurrentCreationWizard();
+ this.getSmooksConfigurationFileGenerateContext().addProperties(
+ cw.getProperties());
String typeID = cw.getInputDataTypeID();
if (UIUtils.setTheProvidersForTreeViewer(viewer, typeID)) {
if (viewer.getInput() != null) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -11,6 +11,7 @@
package org.jboss.tools.smooks.ui.modelparser;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
@@ -134,4 +135,13 @@
return properties;
}
+ public void addProperties(Properties properties){
+ if(properties == null) return;
+ Enumeration keys = properties.keys();
+ while(keys.hasMoreElements()){
+ Object key = keys.nextElement();
+ this.properties.put(key, properties.get(key));
+ }
+ }
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -60,6 +60,10 @@
public Object getReturnValue() {
return returnObject;
}
+
+ public String getFilePath(){
+ return fileText.getText();
+ }
/*
* (non-Javadoc)
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -14,8 +14,8 @@
*/
public abstract class AbstractStructuredDdataWizard extends Wizard implements
IStrucutredDataCreationWizard {
- AbstractFileSelectionWizardPage page = null;
- Object xsdElement = null;
+ protected AbstractFileSelectionWizardPage page = null;
+ protected Object xsdElement = null;
/**
*
*/
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.smooks.xml.ui;
+import java.util.Properties;
+
import org.jboss.tools.smooks.xml.AbstractFileSelectionWizardPage;
import org.jboss.tools.smooks.xml.AbstractStructuredDdataWizard;
import org.jboss.tools.smooks.xml.XmlActivator;
@@ -18,18 +20,34 @@
* @author Dart Peng
* @Date Aug 18, 2008
*/
-public class XMLStructuredDataWizard extends AbstractStructuredDdataWizard{
+public class XMLStructuredDataWizard extends AbstractStructuredDdataWizard {
+ Properties properties = new Properties();
+ String filePath = null;
+ public static final String XML_FILE = "xmlFile";
+
@Override
protected AbstractFileSelectionWizardPage createAbstractFileSelectionWizardPage() {
return new XMLStructuredDataWizardPage("XML");
}
- /* (non-Javadoc)
+ public boolean performFinish() {
+ filePath = page.getFilePath();
+ properties.put(XML_FILE, filePath);
+ return super.performFinish();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.jboss.tools.smooks.ui.IStrucutredDataCreationWizard#getInputDataTypeID()
*/
public String getInputDataTypeID() {
return XmlActivator.TYPE_ID_XML;
}
-
+
+ public Properties getProperties() {
+ return properties;
+ }
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.smooks.xsd.ui;
+import java.util.Properties;
+
import org.jboss.tools.smooks.xml.AbstractFileSelectionWizardPage;
import org.jboss.tools.smooks.xml.AbstractStructuredDdataWizard;
import org.jboss.tools.smooks.xml.XmlActivator;
@@ -19,7 +21,7 @@
* @Date Aug 18, 2008
*/
public class XSDStructuredDataWizard extends AbstractStructuredDdataWizard {
-
+ Properties properties = new Properties();
/* (non-Javadoc)
* @see
org.jboss.tools.smooks.xml.AbstractStructuredDdataWizard#createAbstractFileSelectionWizardPage()
*/
@@ -34,5 +36,8 @@
public String getInputDataTypeID() {
return XmlActivator.TYPE_ID_XSD;
}
+ public Properties getProperties() {
+ return this.properties;
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.xml2java/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.xml2java/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-09-24
08:31:36 UTC (rev 10442)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.xml2java/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-09-24
09:01:53 UTC (rev 10443)
@@ -57,10 +57,6 @@
SmooksConfigurationFileGenerateContext context)
throws SmooksAnalyzerException {
- String filePath = context.getSmooksConfigFile().getLocation()
- .toOSString();
- context.putProperty(XMLSourceModelAnalyzer.XML_FILE, filePath);
-
SmooksResourceListType listType = context.getSmooksResourceListModel();
GraphRootModel rootModel = context.getDataMappingRootModel();
List children = rootModel.getChildren();
@@ -339,6 +335,7 @@
String name = names[i].trim();
if (current instanceof TagObject && isXMLAttributeObject(name)) {
List properties = ((TagObject) current).getProperties();
+ name = name.substring(1);
for (Iterator iterator = properties.iterator(); iterator
.hasNext();) {
TagPropertyObject property = (TagPropertyObject) iterator