JBoss Tools SVN: r10974 - in trunk/smooks: plugins/org.jboss.tools.smooks.ui and 23 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-10-20 06:10:26 -0400 (Mon, 20 Oct 2008)
New Revision: 10974
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j-1.6.1.jar
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/DOM2FreeMarkerTransformor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/FreeMarkerContentReplacer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/utils/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/utils/XMLConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanlabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaStructuredDataModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavabeanStructuredContentsModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelGraphUIProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaImageConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/uitils/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/uitils/JavaPropertyUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/XMLImageConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/DocumentObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStructuredModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStrucutredModelParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizardPage.java
Modified:
trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath
trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/build.properties
trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java
trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF
Log:
JBIDE-2835
For resolve the beta1 bug JBIDE-2835 , and merge the alterations to the trunk
Modified: trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml
===================================================================
--- trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml 2008-10-20 10:08:30 UTC (rev 10973)
+++ trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml 2008-10-20 10:10:26 UTC (rev 10974)
@@ -219,38 +219,17 @@
</license>
<plugin
- id="org.jboss.tools.smooks.javabean"
+ id="org.jboss.tools.smooks.core"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
- id="org.jboss.tools.smooks.model"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.jboss.tools.smooks.model.edit"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
id="org.jboss.tools.smooks.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
- <plugin
- id="org.jboss.tools.smooks.xml"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
</feature>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath 2008-10-20 10:08:30 UTC (rev 10973)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath 2008-10-20 10:10:26 UTC (rev 10974)
@@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src_test"/>
+ <classpathentry kind="lib" path="libs/dom4j-1.6.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2008-10-20 10:08:30 UTC (rev 10973)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2008-10-20 10:10:26 UTC (rev 10974)
@@ -4,32 +4,40 @@
Bundle-SymbolicName: org.jboss.tools.smooks.ui; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.jboss.tools.smooks.ui.SmooksUIActivator
-Require-Bundle: org.eclipse.ui,
+Require-Bundle: org.junit,
+ org.eclipse.ui,
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.forms,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.core.resources,
- org.eclipse.ui.editors,
- org.eclipse.ui.ide,
org.eclipse.gef,
- org.junit,
org.eclipse.jdt.core,
org.eclipse.jdt.ui,
org.eclipse.xsd,
- org.eclipse.ui.forms,
- org.jboss.tools.smooks.model,
org.eclipse.emf,
org.eclipse.emf.edit,
- org.jboss.tools.smooks.model.edit,
- org.eclipse.ui.views.properties.tabbed,
- org.eclipse.emf.edit.ui
+ org.eclipse.emf.edit.ui,
+ org.eclipse.xsd.edit,
+ org.jboss.tools.smooks.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ClassPath: .
+Bundle-ClassPath: .,
+ libs/dom4j-1.6.1.jar
Bundle-Vendor: JBoss
Export-Package: org.jboss.tools.smooks.analyzer,
org.jboss.tools.smooks.graphical,
org.jboss.tools.smooks.graphical.impl,
org.jboss.tools.smooks.graphical.util,
+ org.jboss.tools.smooks.java2xml.analyzer,
+ org.jboss.tools.smooks.java2xml.utils,
+ org.jboss.tools.smooks.javabean.analyzer,
+ org.jboss.tools.smooks.javabean.commandprocessor,
+ org.jboss.tools.smooks.javabean.model,
+ org.jboss.tools.smooks.javabean.ui,
+ org.jboss.tools.smooks.javabean.uitils,
org.jboss.tools.smooks.ui,
org.jboss.tools.smooks.ui.editors,
org.jboss.tools.smooks.ui.gef,
@@ -45,4 +53,11 @@
org.jboss.tools.smooks.ui.gef.util.figures,
org.jboss.tools.smooks.ui.modelparser,
org.jboss.tools.smooks.ui.wizards,
- org.jboss.tools.smooks.utils
+ org.jboss.tools.smooks.utils,
+ org.jboss.tools.smooks.xml,
+ org.jboss.tools.smooks.xml.model,
+ org.jboss.tools.smooks.xml.ui,
+ org.jboss.tools.smooks.xml2java.analyzer,
+ org.jboss.tools.smooks.xml2xml,
+ org.jboss.tools.smooks.xsd.model,
+ org.jboss.tools.smooks.xsd.ui
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/build.properties
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/build.properties 2008-10-20 10:08:30 UTC (rev 10973)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/build.properties 2008-10-20 10:10:26 UTC (rev 10974)
@@ -4,4 +4,5 @@
META-INF/,\
.,\
icons/,\
- libs/
+ libs/,\
+ libs/dom4j-1.6.1.jar
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j-1.6.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-10-20 10:08:30 UTC (rev 10973)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-10-20 10:10:26 UTC (rev 10974)
@@ -68,4 +68,94 @@
name="Smooks Configuration File">
</wizard>
</extension>
+
+ <extension
+ point="org.jboss.tools.smooks.ui.viewerInitor">
+ <viewerInitor
+ contentProvider="org.jboss.tools.smooks.xml.ui.XMLStructuredDataContentProvider"
+ creationWizard="org.jboss.tools.smooks.xml.ui.XMLStructuredDataWizard"
+ description="XML data type comes from any .xml file."
+ labelProvider="org.jboss.tools.smooks.xml.ui.XMLStructuredDataLabelProvider"
+ name="XML Data Type"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ </viewerInitor>
+ </extension>
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.xml2xml.XML2XMLAnalyzer"
+ name="XML2XML Analyzer"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ <targetSourceType
+ id="org.jboss.tools.smooks.xml.viewerInitor.xml"
+ name="XML">
+ </targetSourceType>
+ </mappingAnalyzer>
+ </extension>
+ <extension
+ point="org.jboss.tools.smooks.ui.viewerInitor">
+ <viewerInitor
+ contentProvider="org.jboss.tools.smooks.javabean.model.BeanContentProvider"
+ creationWizard="org.jboss.tools.smooks.javabean.ui.NewJavaBeanStrucutredDataWizard"
+ description="This data type can get from any Java .class."
+ labelProvider="org.jboss.tools.smooks.javabean.model.BeanlabelProvider"
+ name="JavaBean Data Type"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </viewerInitor>
+ </extension>
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ name="JavaBean Analyzer"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ <targetSourceType
+ id="org.jboss.tools.smooks.ui.viewerInitor.javabean"
+ name="java2java">
+ </targetSourceType>
+ </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>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.java2xml.analyzer.Java2XMLAnalyzer"
+ name="Java Bean"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ <targetSourceType
+ id="org.jboss.tools.smooks.xml.viewerInitor.xml"
+ name="XML">
+ </targetSourceType>
+ </mappingAnalyzer>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.xml2java.analyzer.XML2JavaAnalyzer"
+ name="XML2Java"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ <targetSourceType
+ id="org.jboss.tools.smooks.ui.viewerInitor.javabean"
+ name="JavaBean">
+ </targetSourceType>
+ </mappingAnalyzer>
+ <sourceModelAnalyzer
+ class="org.jboss.tools.smooks.xml2java.analyzer.XMLSourceModelAnalyzer"
+ name="XML"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ </sourceModelAnalyzer>
+ </extension>
</plugin>
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/DOM2FreeMarkerTransformor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/DOM2FreeMarkerTransformor.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/DOM2FreeMarkerTransformor.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.java2xml.analyzer;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.jboss.tools.smooks.java2xml.utils.XMLConstants;
+
+/**
+ * @author Dart Peng
+ * @Date : Sep 25, 2008
+ */
+public class DOM2FreeMarkerTransformor {
+
+ public String transformDOM(Document document) {
+ Element element = document.getRootElement();
+ StringBuffer buffer = new StringBuffer();
+ transform(element, buffer);
+ return buffer.toString();
+ }
+
+ protected void transform(Element element, StringBuffer buffer) {
+ String name = element.getName();
+ if (XMLConstants.REPLACE_FREEMARKER_FOR_EXPRESS_ELEMENT_NAME
+ .equals(name)) {
+ String desc = element
+ .attributeValue(XMLConstants.REPLACE_FREEMARKER_FOR_EXPRESS_ELEMENT_ATTRIBUTE);
+ name = "#" + desc;
+ }
+ String attributesString = "";
+ if(!isFreeMarkerExpression(name)){
+ attributesString = buildAttributeString(element);
+ }
+ List children = element.elements();
+ if (children.isEmpty()) {
+ buffer.append("<" + name + " " +attributesString + "/>");
+ return;
+ } else {
+ buffer.append("<" + name + " " +attributesString + "/>");
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ Element child = (Element) iterator.next();
+ transform(child, buffer);
+ }
+ if(isFreeMarkerExpression(name)){
+ name = name.trim();
+ int index = name.indexOf(" ");
+ if(index != -1){
+ name = name.substring(0,index);
+ }
+ }
+ buffer.append("</" + name + ">");
+ }
+ }
+
+ private String buildAttributeString(Element element) {
+ List list = element.attributes();
+ StringBuffer buffer = new StringBuffer("");
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ Attribute att = (Attribute) iterator.next();
+ String name = att.getName();
+ String value = att.getValue();
+ if(value == null) value = "";
+ if(name != null){
+ buffer.append(name);
+ buffer.append("=");
+ buffer.append("\"");
+ buffer.append(value);
+ buffer.append("\"");
+ buffer.append(" ");
+ }
+ }
+ return buffer.toString();
+ }
+
+ private boolean isFreeMarkerExpression(String str){
+ return str.startsWith("#");
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/DOM2FreeMarkerTransformor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/FreeMarkerContentReplacer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/FreeMarkerContentReplacer.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/FreeMarkerContentReplacer.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.java2xml.analyzer;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+/**
+ * @author Dart Peng
+ * @Date : Sep 25, 2008
+ */
+public class FreeMarkerContentReplacer {
+
+ public String replaceFreeMarkerTemplate(Reader reader) throws IOException {
+ StringBuffer buffer = new StringBuffer();
+// Configuration fmConfiguration = new Configuration();
+// fmConfiguration.setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX);
+//
+// Template template;
+// template = new Template("XML2Java_FreeMarker", reader, fmConfiguration);
+// TemplateElement root = template.getRootTreeNode();
+// visitTemplateElement(root, buffer);
+ return buffer.toString();
+ }
+
+ public String replaceFreeMarkerTemplate(String templateContents)
+ throws IOException {
+ Reader reader = new StringReader(templateContents);
+ return replaceFreeMarkerTemplate(reader);
+ }
+
+// private void visitTemplateElement(TemplateElement model, StringBuffer buffer) {
+
+// Enumeration children = ((TemplateElement) model).children();
+// if (!"MixedContent".equals(model.getNodeName())) {
+// buffer
+// .append("<"
+// + XMLConstants.REPLACE_FREEMARKER_FOR_EXPRESS_ELEMENT_NAME
+// + " "
+// + XMLConstants.REPLACE_FREEMARKER_FOR_EXPRESS_ELEMENT_ATTRIBUTE
+// + "= \"" + model.getDescription() + "\">");
+// }
+// while (children.hasMoreElements()) {
+// Object obj = children.nextElement();
+// if (!(obj instanceof TextBlock)) {
+// TemplateElement child = (TemplateElement) obj;
+// String str = child.getSource();
+// if (child.isLeaf()) {
+// if (child.getNodeName().equals("DollarVariable")) {
+// buffer.append(child.getSource());
+// } else {
+// buffer.append(child.getDescription());
+// }
+// continue;
+// }
+// visitTemplateElement(child, buffer);
+// } else {
+// buffer.append(obj);
+// }
+// }
+// if (!"MixedContent".equals(model.getNodeName())) {
+// buffer.append("</"
+// + XMLConstants.REPLACE_FREEMARKER_FOR_EXPRESS_ELEMENT_NAME
+// + ">");
+// }
+// }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/FreeMarkerContentReplacer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * 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.java2xml.analyzer;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.analyzer.AbstractAnalyzer;
+import org.jboss.tools.smooks.analyzer.DesignTimeAnalyzeResult;
+import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
+import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.model.ParamType;
+import org.jboss.tools.smooks.model.ResourceConfigType;
+import org.jboss.tools.smooks.model.SmooksFactory;
+import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
+import org.jboss.tools.smooks.ui.gef.model.GraphRootModel;
+import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
+import org.jboss.tools.smooks.ui.gef.model.SourceModel;
+import org.jboss.tools.smooks.ui.gef.model.TargetModel;
+import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+import org.jboss.tools.smooks.utils.UIUtils;
+import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
+import org.jboss.tools.smooks.xml.model.DocumentObject;
+import org.jboss.tools.smooks.xml.model.TagObject;
+import org.jboss.tools.smooks.xml.model.TagPropertyObject;
+
+/**
+ *
+ * @author <a href="mailto:dpeng@redhat.com">Dart Peng</a>
+ * @Date 2008-9-22
+ */
+public class Java2XMLAnalyzer extends AbstractAnalyzer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel(org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext)
+ */
+ public void analyzeMappingGraphModel(
+ SmooksConfigurationFileGenerateContext context)
+ throws SmooksAnalyzerException {
+ // TODO will modify soon
+
+ if(true){
+ Shell shell = context.getShell();
+ MessageDialog.openWarning(shell, "Warning", "The java2xml can't be generate to config file currently.");
+ return;
+ }
+
+ GraphRootModel rootModel = context.getGraphicalRootModel();
+ List<SourceModel> sourceModelList = rootModel.loadSourceModelList();
+ List<TargetModel> targetModelList = rootModel.loadTargetModelList();
+
+ // Element rootElement = DocumentHelper.createElement(name);
+ TagObject root = null;
+ for (Iterator iterator = targetModelList.iterator(); iterator.hasNext();) {
+ TargetModel targetModel = (TargetModel) iterator.next();
+ AbstractXMLObject tag = (AbstractXMLObject) targetModel
+ .getReferenceEntityModel();
+ root = findTheRootTagObject(tag);
+ break;
+ }
+
+ if (root == null)
+ throw new SmooksAnalyzerException("can't find the root element");
+ Document document = DocumentHelper.createDocument();
+ Element rootElement = generateXMLContents(rootModel, root);
+ document.setRootElement(rootElement);
+
+ String string = document.asXML();
+
+ ResourceConfigType resource = SmooksFactory.eINSTANCE
+ .createResourceConfigType();
+ ParamType param = SmooksFactory.eINSTANCE.createParamType();
+ resource.getParam().add(param);
+ SmooksModelUtils.appendTextToSmooksType(param, string);
+ context.getGeneratorResourceList().add(resource);
+ System.out.println(string);
+ }
+
+ protected Element generateXMLContents(GraphRootModel graph, TagObject tag) {
+ Element element = DocumentHelper.createElement(tag.getName());
+ AbstractStructuredDataModel dataModel = UIUtils.findGraphModel(graph,
+ tag);
+ generateElementAttribute(graph, element, tag.getProperties());
+ List children = tag.getChildren();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ TagObject child = (TagObject) iterator.next();
+ element.add(generateXMLContents(graph, child));
+ }
+
+ if (dataModel != null) {
+ LineConnectionModel connection = UIUtils
+ .getFirstTargetModelViaConnection(dataModel);
+ if (connection != null) {
+ SourceModel source = (SourceModel) connection.getSource();
+ element
+ .add(DocumentHelper
+ .createCDATA(getTheJavaBeanString((JavaBeanModel) source
+ .getReferenceEntityModel())));
+ }
+ }
+
+ return element;
+ }
+
+ protected void generateElementAttribute(GraphRootModel graph,
+ Element element, List<TagPropertyObject> properties) {
+ for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
+ TagPropertyObject tagPropertyObject = (TagPropertyObject) iterator
+ .next();
+
+ AbstractStructuredDataModel dataModel = UIUtils.findGraphModel(
+ graph, tagPropertyObject);
+ LineConnectionModel connect = UIUtils
+ .getFirstTargetModelViaConnection(dataModel);
+ if (connect == null)
+ continue;
+
+ SourceModel source = (SourceModel) connect.getSource();
+
+ element.addAttribute(tagPropertyObject.getName(),
+ getTheJavaBeanString((JavaBeanModel) source
+ .getReferenceEntityModel()));
+ }
+ }
+
+ protected TagObject findTheRootTagObject(AbstractXMLObject obj) {
+ AbstractXMLObject parent = obj.getParent();
+ if (parent instanceof DocumentObject && obj instanceof TagObject)
+ return (TagObject) obj;
+ return (TagObject) findTheRootTagObject(parent);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingSmooksModel(org.jboss.tools.smooks.model.SmooksResourceListType,
+ * java.lang.Object, java.lang.Object)
+ */
+ public MappingResourceConfigList analyzeMappingSmooksModel(
+ SmooksResourceListType listType, Object sourceObject,
+ Object targetObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected String getTheJavaBeanString(JavaBeanModel currentModel) {
+ String name = currentModel.getName();
+ JavaBeanModel parent = currentModel.getParent();
+ while (parent != null ) {
+ String pn = parent.getName();
+ if (pn != null) {
+ name = parent.getName() + "." + name;
+ }
+ parent = parent.getParent();
+ }
+ return "${" + name + "}";
+ }
+
+ public DesignTimeAnalyzeResult analyzeGraphModel(
+ SmooksConfigurationFileGenerateContext context) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/utils/XMLConstants.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/utils/XMLConstants.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/utils/XMLConstants.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.java2xml.utils;
+
+/**
+ * @author Dart Peng
+ * @Date : Sep 25, 2008
+ */
+public class XMLConstants {
+ public static final String REPLACE_FREEMARKER_FOR_EXPRESS_ELEMENT_NAME = "replaceElementNameForFreeMarker";
+
+ public static final String REPLACE_FREEMARKER_FOR_EXPRESS_ELEMENT_ATTRIBUTE = "desc";
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/utils/XMLConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,1014 @@
+/*******************************************************************************
+ * 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.javabean.analyzer;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.common.command.BasicCommandStack;
+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.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.analyzer.DesignTimeAnalyzeResult;
+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.MappingResourceConfigList;
+import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
+import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModelFactory;
+import org.jboss.tools.smooks.model.AbstractResourceConfig;
+import org.jboss.tools.smooks.model.ParamType;
+import org.jboss.tools.smooks.model.ResourceConfigType;
+import org.jboss.tools.smooks.model.ResourceType;
+import org.jboss.tools.smooks.model.SmooksFactory;
+import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.model.provider.SmooksItemProviderAdapterFactory;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
+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;
+import org.jboss.tools.smooks.utils.UIUtils;
+
+/**
+ * @author Dart Peng
+ *
+ */
+public class JavaBeanAnalyzer implements IMappingAnalyzer,
+ ISourceModelAnalyzer, ITargetModelAnalyzer {
+
+ public static final String BEANPOPULATOR = "org.milyn.javabean.BeanPopulator";
+
+ public static final String PRO_CLASS_NAME = "__pro_class_name_";
+
+ public static final Object PRO_PROJECT_NAME = "__pro_project_name_";
+
+ public static final String SPACE_STRING = " ";
+
+ private List usedConnectionList = new ArrayList();
+
+ private ComposedAdapterFactory adapterFactory;
+
+ private AdapterFactoryEditingDomain editingDomain;
+
+ private HashMap userdResourceTypeMap = new HashMap();
+
+ private HashMap usedBeanIDMap = new HashMap();
+
+ public JavaBeanAnalyzer() {
+
+ adapterFactory = new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ adapterFactory
+ .addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory
+ .addAdapterFactory(new SmooksItemProviderAdapterFactory());
+
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
+ createCommandStack(), new HashMap<Resource, Boolean>());
+ }
+
+ protected CommandStack createCommandStack() {
+ return new BasicCommandStack();
+ }
+
+ public void analyzeGraphicalModel(AbstractStructuredDataModel root,
+ List resouceList) {
+
+ List children = root.getChildren();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ TreeItemRelationModel dataModel = (TreeItemRelationModel) iterator
+ .next();
+ List targetConnections = dataModel.getModelTargetConnections();
+ if (targetConnections != null && !targetConnections.isEmpty()) {
+ this.analyzeStructuredDataModel(resouceList, root, dataModel,
+ null, null);
+ }
+ }
+ }
+
+ protected void setSelectorIsUsed(String selector) {
+ userdResourceTypeMap.put(selector, new Object());
+ }
+
+ protected boolean beanIDIsUsed(String beanID) {
+ return (usedBeanIDMap.get(beanID) != null);
+ }
+
+ protected void setBeanIDIsUsed(String beanID) {
+ usedBeanIDMap.put(beanID, new Object());
+ }
+
+ protected boolean isSelectorIsUsed(String resourceType) {
+ return (userdResourceTypeMap.get(resourceType) != null);
+ }
+
+ private boolean connectionIsUsed(Object connection) {
+ return (usedConnectionList.indexOf(connection) != -1);
+ }
+
+ private void setConnectionUsed(Object connection) {
+ usedConnectionList.add(connection);
+ }
+
+ /**
+ *
+ * @param resourceList
+ * @param root
+ * @param dataModel
+ * @param parentResourceConfigType
+ * @param beanId
+ */
+ protected void analyzeStructuredDataModel(List resourceList,
+ AbstractStructuredDataModel root,
+ AbstractStructuredDataModel dataModel,
+ ResourceConfigType parentResourceConfigType, String beanId) {
+ if (dataModel instanceof IConnectableModel) {
+ // if the mode have no target connections, return
+ if (((IConnectableModel) dataModel).getModelTargetConnections()
+ .isEmpty())
+ return;
+ // if the datamodel is a root structured data model
+ if (dataModel instanceof IConnectableModel) {
+ List targetConnections = ((IConnectableModel) dataModel)
+ .getModelTargetConnections();
+ for (Iterator iterator = targetConnections.iterator(); iterator
+ .hasNext();) {
+ LineConnectionModel connection = (LineConnectionModel) iterator
+ .next();
+ if (connectionIsUsed(connection))
+ continue;
+ Object source = connection.getSource();
+ Object target = connection.getTarget();
+ if (target != dataModel) {
+ continue;
+ }
+ // create the first smooks resource fragment
+
+ JavaBeanModel sourceJavaBean = (JavaBeanModel) ((AbstractStructuredDataModel) source)
+ .getReferenceEntityModel();
+ JavaBeanModel targetJavaBean = (JavaBeanModel) ((AbstractStructuredDataModel) target)
+ .getReferenceEntityModel();
+ String sourceClassName = sourceJavaBean.getBeanClass()
+ .getName();
+
+ ResourceConfigType resourceConfig = SmooksFactory.eINSTANCE
+ .createResourceConfigType();
+ resourceList.add(resourceConfig);
+ // Command addResourceConfigCommand = AddCommand
+ // .create(
+ // editingDomain,
+ // resourceList,
+ // SmooksPackage.eINSTANCE
+ // .getSmooksResourceListType_AbstractResourceConfig(),
+ // resourceConfig);
+ // addResourceConfigCommand.execute();
+ // resouceConfig.
+ resourceConfig
+ .setSelector(getSourceBeanSelectorString((AbstractStructuredDataModel) source));
+ setConnectionUsed(connection);
+
+ ResourceType resource = SmooksFactory.eINSTANCE
+ .createResourceType();
+ resource.setValue(BEANPOPULATOR);
+ resourceConfig.setResource(resource);
+
+ ParamType beanIdParam = SmooksFactory.eINSTANCE
+ .createParamType();
+ beanIdParam.setName("beanId");
+ if (beanId == null)
+ beanId = targetJavaBean.getName();
+ if (beanId.startsWith("${")) {
+ beanId = beanId.substring(2, beanId.indexOf("}"));
+ }
+ SmooksModelUtils
+ .appendTextToSmooksType(beanIdParam, beanId);
+ resourceConfig.getParam().add(beanIdParam);
+
+ ParamType beanClassParam = SmooksFactory.eINSTANCE
+ .createParamType();
+ beanClassParam.setName("beanClass");
+ SmooksModelUtils.appendTextToSmooksType(beanClassParam,
+ targetJavaBean.getBeanClassString());
+ resourceConfig.getParam().add(beanClassParam);
+
+ ParamType bindingsParam = SmooksFactory.eINSTANCE
+ .createParamType();
+ bindingsParam.setName("bindings");
+ resourceConfig.getParam().add(bindingsParam);
+
+ // to dispatch the target's children (Order processing)
+
+ List children = targetJavaBean.getProperties();
+ for (Iterator iterator2 = children.iterator(); iterator2
+ .hasNext();) {
+ JavaBeanModel childJavaBean = (JavaBeanModel) iterator2
+ .next();
+ AbstractStructuredDataModel child = UIUtils
+ .findGraphModel(
+ (AbstractStructuredDataModel) root,
+ childJavaBean);
+ if (child == null)
+ continue;
+ if (child instanceof IConnectableModel) {
+ if (((IConnectableModel) child)
+ .getModelTargetConnections().isEmpty())
+ continue;
+ // how dispatch more than one connection???
+ List<Object> targetConnectionModelList = ((IConnectableModel) child)
+ .getModelTargetConnections();
+ for (Iterator iterator3 = targetConnectionModelList
+ .iterator(); iterator3.hasNext();) {
+ LineConnectionModel childConnection = (LineConnectionModel) iterator3
+ .next();
+ if (connectionIsUsed(childConnection))
+ continue;
+ Object[] properties = childConnection
+ .getPropertyArray();
+ JavaBeanModel jbean = (JavaBeanModel) child
+ .getReferenceEntityModel();
+ String currentSelectorName = getSelectorString(
+ (AbstractStructuredDataModel) childConnection
+ .getTarget(),
+ (AbstractStructuredDataModel) childConnection
+ .getSource(),
+ (AbstractStructuredDataModel) source);
+ 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,
+ resourceConfig, currentSelectorName);
+ }
+ this.setConnectionUsed(childConnection);
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param target
+ * @param source
+ * @param currentRootModel
+ * @return
+ */
+ protected String getSelectorString(AbstractStructuredDataModel target,
+ AbstractStructuredDataModel source,
+ AbstractStructuredDataModel currentRootModel) {
+ JavaBeanModel sourcebean = (JavaBeanModel) source
+ .getReferenceEntityModel();
+ JavaBeanModel rootbean = (JavaBeanModel) currentRootModel
+ .getReferenceEntityModel();
+ JavaBeanModel currentbean = (JavaBeanModel) target
+ .getReferenceEntityModel();
+ if (sourcebean.getParent() == currentRootModel
+ .getReferenceEntityModel()) {
+ if (!currentbean.isPrimitive()) {
+ return "${" + currentbean.getName() + "}";
+ } else {
+ return rootbean.getBeanClassString() + " "
+ + sourcebean.getName();
+ }
+ } else {
+ JavaBeanModel jbParent = ((JavaBeanModel) source
+ .getReferenceEntityModel()).getParent();
+ AbstractStructuredDataModel parent = UIUtils.findGraphModel(
+ currentRootModel.getParent(), jbParent);
+ String returnString = sourcebean.getName();
+ while (parent != currentRootModel && parent != null) {
+ JavaBeanModel jbm = (JavaBeanModel) parent
+ .getReferenceEntityModel();
+ if (jbm != null)
+ returnString = jbm.getName() + " " + returnString;
+
+ JavaBeanModel jb = ((JavaBeanModel) parent
+ .getReferenceEntityModel()).getParent();
+ parent = UIUtils.findGraphModel(currentRootModel.getParent(),
+ jb);
+ }
+ // if no property
+ if (returnString.equals(sourcebean.getName())) {
+ returnString = ((JavaBeanModel) parent
+ .getReferenceEntityModel()).getBeanClassString()
+ + " " + returnString;
+ }
+ return returnString;
+ }
+ }
+
+ protected String getSourceBeanSelectorString(
+ AbstractStructuredDataModel sourceModel) {
+ JavaBeanModel source = (JavaBeanModel) sourceModel
+ .getReferenceEntityModel();
+ if(source.getBeanClass().isArray()){
+ return source.getName();
+ }
+ if (Collection.class.isAssignableFrom(source.getBeanClass())) {
+ return source.getName();
+ }
+ return source.getBeanClassString();
+
+ }
+
+ private DesignTimeAnalyzeResult checkOtherNodeConnected(
+ SmooksConfigurationFileGenerateContext context) {
+ GraphRootModel root = context.getGraphicalRootModel();
+ List sourceList = root.loadSourceModelList();
+ List targetList = root.loadTargetModelList();
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator iterator = targetList.iterator(); iterator.hasNext();) {
+ AbstractStructuredDataModel targetm = (AbstractStructuredDataModel) iterator
+ .next();
+ if (targetm instanceof IConnectableModel) {
+ if (((IConnectableModel) targetm).getModelTargetConnections()
+ .isEmpty()) {
+ continue;
+ }
+
+ JavaBeanModel javaModel = (JavaBeanModel) targetm
+ .getReferenceEntityModel();
+ JavaBeanModel parent = javaModel.getParent();
+ if (parent != null) {
+ AbstractStructuredDataModel pgm = UIUtils.findGraphModel(
+ root, parent);
+ if (pgm != null && pgm instanceof IConnectableModel) {
+ if (((IConnectableModel) pgm)
+ .getModelTargetConnections().isEmpty()) {
+ buffer
+ .append("The parent of Java node \""
+ + javaModel.getName()
+ + "\" : \""
+ + parent.getName()
+ + "\" doesn't be connected by any source node!\n");
+ }
+ }
+ }
+ }
+ }
+ String result = buffer.toString();
+ if ("".equals(result)) {
+ return null;
+ }
+ DesignTimeAnalyzeResult dr = new DesignTimeAnalyzeResult();
+ dr.setErrorMessage(result);
+ return dr;
+ }
+
+ /**
+ * If root node don't connect , it will ask user to connect them .
+ *
+ * @param context
+ */
+ private void checkRootNodeConnected(
+ SmooksConfigurationFileGenerateContext context) {
+ GraphRootModel root = context.getGraphicalRootModel();
+ List sourceList = root.loadSourceModelList();
+ List targetList = root.loadTargetModelList();
+
+ JavaBeanModel rootSource = null;
+ JavaBeanModel rootTarget = null;
+ boolean needCheck = false;
+
+ for (Iterator iterator = sourceList.iterator(); iterator.hasNext();) {
+ AbstractStructuredDataModel sourcegm = (AbstractStructuredDataModel) iterator
+ .next();
+ if (sourcegm instanceof IConnectableModel) {
+ if (!((IConnectableModel) sourcegm).getModelSourceConnections()
+ .isEmpty()
+ || !((IConnectableModel) sourcegm)
+ .getModelTargetConnections().isEmpty()) {
+ needCheck = true;
+ break;
+ }
+ }
+ }
+
+ if (needCheck) {
+ for (Iterator iterator = sourceList.iterator(); iterator.hasNext();) {
+ AbstractStructuredDataModel sourceGraphModel = (AbstractStructuredDataModel) iterator
+ .next();
+ JavaBeanModel source = (JavaBeanModel) sourceGraphModel
+ .getReferenceEntityModel();
+ if (source.isRoot()) {
+ rootSource = source;
+ break;
+ }
+ }
+
+ for (Iterator iterator = targetList.iterator(); iterator.hasNext();) {
+ AbstractStructuredDataModel targetGraphModel = (AbstractStructuredDataModel) iterator
+ .next();
+ JavaBeanModel target = (JavaBeanModel) targetGraphModel
+ .getReferenceEntityModel();
+ if (target.isRoot()) {
+ rootTarget = target;
+ break;
+ }
+ }
+ if (rootSource != null && rootTarget != null) {
+ AbstractStructuredDataModel rootSourceGraphModel = UIUtils
+ .findGraphModel(root, rootSource);
+ AbstractStructuredDataModel rootTargetGraphModel = UIUtils
+ .findGraphModel(root, rootTarget);
+ if (rootSourceGraphModel instanceof IConnectableModel
+ && rootTargetGraphModel instanceof IConnectableModel) {
+ if (((IConnectableModel) rootSourceGraphModel)
+ .isSourceConnectWith((IConnectableModel) rootTargetGraphModel)) {
+ // do nothing
+ } else {
+ // ask user if they want to connect the root model
+ Shell displayParent = context.getShell();
+ boolean connectAuto = MessageDialog
+ .openQuestion(
+ displayParent,
+ "Connection Question",
+ "The root models don't be connected , it will make some errors with the generation config file contents.\nDo you wan to connect them?");
+ if (connectAuto) {
+ // connect root model
+ LineConnectionModel connectionModel = new LineConnectionModel();
+ connectionModel
+ .setSource((IConnectableModel) rootSourceGraphModel);
+ connectionModel
+ .setTarget((IConnectableModel) rootTargetGraphModel);
+ connectionModel.connect();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel(org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext)
+ */
+ public void analyzeMappingGraphModel(
+ SmooksConfigurationFileGenerateContext context)
+ throws SmooksAnalyzerException {
+ GraphRootModel root = context.getGraphicalRootModel();
+ this.analyzeGraphicalModel(root, context.getGeneratorResourceList());
+ }
+
+ public MappingResourceConfigList analyzeMappingSmooksModel(
+ SmooksResourceListType listType, Object sourceObject,
+ Object targetObject) {
+ if (sourceObject instanceof List) {
+ if (!((List) sourceObject).isEmpty()) {
+ sourceObject = (JavaBeanModel) ((List) sourceObject).get(0);
+ }
+ }
+ if (targetObject instanceof List) {
+ if (!((List) targetObject).isEmpty()) {
+ targetObject = (JavaBeanModel) ((List) targetObject).get(0);
+ }
+ }
+ if (!(sourceObject instanceof JavaBeanModel)
+ || !(targetObject instanceof JavaBeanModel)) {
+ return MappingResourceConfigList.createEmptyList();
+ }
+ MappingResourceConfigList resourceConfigList = new MappingResourceConfigList();
+ JavaBeanModel source = (JavaBeanModel) sourceObject;
+ JavaBeanModel target = (JavaBeanModel) targetObject;
+ List<MappingModel> mappingModelList = new ArrayList<MappingModel>();
+ List<AbstractResourceConfig> rcl = listType.getAbstractResourceConfig();
+ for (Iterator iterator = rcl.iterator(); iterator.hasNext();) {
+ ResourceConfigType rc = (ResourceConfigType) iterator.next();
+ ResourceType rt = rc.getResource();
+ // find the first BeanPopulator resource config , this is the root.
+ if (rt != null && BEANPOPULATOR.equals(rt.getValue())) {
+ String sourceName = source.getName();
+ Class sourceClazz = source.getBeanClass();
+ if (sourceClazz != null) {
+ sourceName = sourceClazz.getName();
+ }
+ String selector = rc.getSelector();
+ if (sourceName.equals(selector)) {
+ String targetName = target.getName();
+ Class targetClazz = target.getBeanClass();
+ if (targetClazz != null) {
+ targetName = targetClazz.getName();
+ }
+ String beanClass = SmooksModelUtils.getParmaText(
+ "beanClass", rc);
+ if (targetName!=null && targetName.trim().equals(beanClass)) {
+ setSelectorIsUsed(sourceName);
+ // create the first connection
+ mappingModelList.add(new MappingModel(source, target));
+ resourceConfigList.addResourceConfig(rc);
+ analyzeMappingModelFromResourceConfig(mappingModelList,
+ resourceConfigList, listType, rc, source,
+ target);
+ }
+ }
+ }
+ }
+ resourceConfigList.setMappingModelList(mappingModelList);
+ return resourceConfigList;
+ }
+
+ protected boolean isReferenceSelector(String selector) {
+ return (selector.startsWith("${") && selector.endsWith("}"));
+ }
+
+ protected String getBeanIdWithRawSelectorString(String selector) {
+ selector = selector.substring(2, selector.length() - 1);
+ return selector;
+ }
+
+ protected void analyzeMappingModelFromResourceConfig(
+ List<MappingModel> mappingModelList,
+ MappingResourceConfigList mappingResourceConfigList,
+ SmooksResourceListType resourceList,
+ ResourceConfigType resourceConfig, JavaBeanModel source,
+ 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(
+ binding, SmooksModelUtils.ATTRIBUTE_PROPERTY);
+ String selector = SmooksModelUtils.getAttributeValueFromAnyType(
+ binding, SmooksModelUtils.ATTRIBUTE_SELECTOR);
+ JavaBeanModel targetModel = findTheChildJavaBeanModel(property,
+ target);
+ JavaBeanModel sourceModel = null;
+ if (targetModel == null)
+ continue;
+ if (isReferenceSelector(selector)) {
+ ResourceConfigType rc = this
+ .findResourceConfigTypeWithSelector(selector,
+ resourceList);
+ if (rc != null) {
+ String newSelector = rc.getSelector();
+ sourceModel = findTheChildJavaBeanModel(newSelector, source);
+ if (sourceModel != null) {
+ setSelectorIsUsed(newSelector);
+ mappingResourceConfigList.addResourceConfig(rc);
+ analyzeMappingModelFromResourceConfig(mappingModelList,
+ mappingResourceConfigList, resourceList, rc,
+ sourceModel, targetModel);
+ }
+ }
+ } else {
+ sourceModel = findModelWithSelectorString(selector, source);
+ }
+ 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);
+ }
+ }
+ }
+
+ protected JavaBeanModel findModelWithSelectorString(String selector,
+ JavaBeanModel parentModel) {
+ String[] s = selector.trim().split(" ");
+ String pname = parentModel.getName();
+ Class clazz = parentModel.getBeanClass();
+ JavaBeanModel current = parentModel;
+ if (clazz != null)
+ pname = clazz.getName();
+ if (s != null) {
+ for (int i = 0; i < s.length; i++) {
+ String p = s[i];
+ if (p.equals(pname))
+ continue;
+ JavaBeanModel child = findTheChildJavaBeanModel(p, current);
+ if (child == null)
+ return null;
+ current = child;
+ }
+ return current;
+ }
+ return null;
+ }
+
+ public Object buildSourceInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile,
+ ClassLoader classLoader) throws InvocationTargetException {
+ List resourceConfigList = listType.getAbstractResourceConfig();
+ String rootClassName = null;
+ ResourceConfigType current = null;
+ for (Iterator iterator = resourceConfigList.iterator(); iterator
+ .hasNext();) {
+ AbstractResourceConfig ar = (AbstractResourceConfig) iterator
+ .next();
+ if (ar instanceof ResourceConfigType) {
+ ResourceConfigType rc = (ResourceConfigType) ar;
+ ResourceType resourceType = rc.getResource();
+ if (resourceType == null)
+ continue;
+ String resource = resourceType.getValue();
+ if (BEANPOPULATOR.equals(resource)) {
+ // create root beanmodel
+ rootClassName = rc.getSelector();
+ current = rc;
+ break;
+ }
+ }
+ }
+
+ if (rootClassName == null)
+ return null;
+
+ boolean isWarning = false;
+ boolean isError = false;
+ Class clazz = null;
+ try {
+ if (classLoader == null) {
+ IProject project = sourceFile.getProject();
+ classLoader = new ProjectClassLoader(JavaCore.create(project));
+ }
+
+ clazz = classLoader.loadClass(rootClassName);
+ } catch (Exception e) {
+ // ignore
+ }
+ JavaBeanModel model = null;
+ if (clazz != null) {
+ model = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
+ } else {
+ model = new JavaBeanModel(null, rootClassName);
+ model.setRootClassModel(true);
+ model.setError("Can't find the class : " + rootClassName);
+ model.setProperties(new ArrayList());
+ isError = true;
+ }
+ if (model != null) {
+ this.setSelectorIsUsed(rootClassName);
+ buildSourceInputProperties(listType, model, false, isError,
+ current, classLoader);
+ }
+ List list = new ArrayList();
+ if (model != null)
+ list.add(model);
+ return list;
+ }
+
+ public Object buildSourceInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException {
+ return this.buildSourceInputObjects(graphInfo, listType, sourceFile,
+ null);
+ }
+
+ public Object buildTargetInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException {
+ return this.buildTargetInputObjects(graphInfo, listType, sourceFile,
+ null);
+ }
+
+ public Object buildTargetInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile,
+ ClassLoader loader) throws InvocationTargetException {
+ if (loader == null) {
+ try {
+ loader = new ProjectClassLoader(JavaCore.create(sourceFile
+ .getProject()));
+ } catch (JavaModelException e) {
+ // ignore
+ }
+ }
+ List resourceConfigList = listType.getAbstractResourceConfig();
+ String rootClassName = null;
+ ResourceConfigType current = null;
+ for (Iterator iterator = resourceConfigList.iterator(); iterator
+ .hasNext();) {
+ AbstractResourceConfig ar = (AbstractResourceConfig) iterator
+ .next();
+ if (ar instanceof ResourceConfigType) {
+ ResourceConfigType rc = (ResourceConfigType) ar;
+ ResourceType resourceType = rc.getResource();
+ if (resourceType == null)
+ continue;
+ String resource = resourceType.getValue();
+ if (BEANPOPULATOR.equals(resource)) {
+ // create root beanmodel
+ current = rc;
+ break;
+ }
+ }
+ }
+ if (current == null)
+ return null;
+ Class rootClass = null;
+ rootClassName = SmooksModelUtils.getParmaText("beanClass", current);
+ if (rootClassName != null && loader != null) {
+ try {
+ rootClass = loader.loadClass(rootClassName);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ }
+ boolean rootIsError = false;
+ JavaBeanModel rootModel = null;
+ if (rootClass != null) {
+ rootModel = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(rootClass);
+ rootIsError = true;
+ } else {
+ rootModel = new JavaBeanModel(null, rootClassName);
+ }
+ setSelectorIsUsed(rootClassName);
+ buildChildrenOfTargetInputModel(listType, rootModel, false,
+ rootIsError, current, loader);
+ List list = new ArrayList();
+ list.add(rootModel);
+ return list;
+ }
+
+ protected void buildChildrenOfTargetInputModel(
+ SmooksResourceListType listType, JavaBeanModel beanModel,
+ boolean rootIsWarning, boolean rootIsError,
+ ResourceConfigType currentResourceConfigType,
+ 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
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_PROPERTY);
+ String selector = SmooksModelUtils
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_SELECTOR);
+ // if(property == null){
+ // continue;
+ // }
+ processBindingPropertyFromTargetModel(listType, property,
+ selector, beanModel, classLoader);
+ }
+ }
+
+ }
+
+ protected void processBindingPropertyFromTargetModel(
+ SmooksResourceListType listType, String property, String selector,
+ JavaBeanModel parentModel, ClassLoader classLoader) {
+ parentModel.getProperties();
+ JavaBeanModel model = this.findTheChildJavaBeanModel(property,
+ parentModel);
+ if (model == null) {
+ model = new JavaBeanModel(null, property);
+ parentModel.addProperty(model);
+ model.setError("don't exist");
+ }
+
+ if (isReferenceSelector(selector)) {
+ selector = selector.substring(2, selector.length() - 1);
+ ResourceConfigType resourceConfig = findResourceConfigTypeWithSelector(
+ selector, listType);
+ if (resourceConfig != null) {
+ this.buildChildrenOfTargetInputModel(listType, model, false,
+ false, resourceConfig, classLoader);
+ }
+ }
+ }
+
+ protected List getBindingListFromResourceConfigType(
+ ResourceConfigType resourceConfig) {
+ List paramList = resourceConfig.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType param = (ParamType) iterator.next();
+ if ("bindings".equals(param.getName())) {
+ if (param.eContents().isEmpty())
+ continue;
+ List bindingList = (List) param.getMixed().get(
+ SmooksModelUtils.ELEMENT_BINDING, false);
+ return bindingList;
+ }
+ }
+ return null;
+ }
+
+ protected void buildSourceInputProperties(SmooksResourceListType listType,
+ JavaBeanModel beanModel, boolean rootIsWarning,
+ boolean rootIsError, ResourceConfigType currentResourceConfigType,
+ ClassLoader classLoader) {
+ if (currentResourceConfigType != null) {
+ List bindingList = this
+ .getBindingListFromResourceConfigType(currentResourceConfigType);
+ if (bindingList == null)
+ return;
+ for (Iterator iterator2 = bindingList.iterator(); iterator2
+ .hasNext();) {
+ AnyType binding = (AnyType) iterator2.next();
+ String selector = SmooksModelUtils
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_SELECTOR);
+ setSelectorIsUsed(currentResourceConfigType.getSelector());
+ analyzeBindingSelector(selector, beanModel, listType,
+ classLoader);
+ }
+ }
+ }
+
+ protected ResourceConfigType findResourceConfigTypeWithSelector(
+ String selector, SmooksResourceListType listType) {
+ if (isReferenceSelector(selector)) {
+ selector = this.getBeanIdWithRawSelectorString(selector);
+ }
+ List rl = listType.getAbstractResourceConfig();
+ ResourceConfigType resourceConfig = null;
+ for (Iterator iterator = rl.iterator(); iterator.hasNext();) {
+ ResourceConfigType rct = (ResourceConfigType) iterator.next();
+ if (this.isSelectorIsUsed(rct.getSelector()))
+ continue;
+ String beanId = getBeanIDFromParam(rct);
+ if (selector.equals(beanId)) {
+ resourceConfig = rct;
+ break;
+ }
+ }
+ return resourceConfig;
+ }
+
+ protected void analyzeBindingSelector(String selector,
+ JavaBeanModel currentModel, SmooksResourceListType listType,
+ ClassLoader classLoader) {
+ if (selector.startsWith("${") && selector.endsWith("}")) {
+ // should get the bean properties
+ // memory out???
+ currentModel.getProperties();
+ selector = this.getBeanIdWithRawSelectorString(selector);
+ ResourceConfigType resourceConfig = findResourceConfigTypeWithSelector(
+ selector, listType);
+ if (resourceConfig != null) {
+ String referenceSelector = resourceConfig.getSelector();
+ JavaBeanModel model = findTheChildJavaBeanModel(
+ referenceSelector, currentModel);
+ // try to test the selector is can be loaded by classloader??
+ Class clazz = null;
+ try {
+ if (classLoader != null) {
+ clazz = classLoader.loadClass(referenceSelector);
+ if (clazz != null && model == null)
+ model = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(clazz);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ // something wrong
+ if (model == null) {
+ model = new JavaBeanModel(null, referenceSelector);
+ model.setError("don't exist");
+ model.setProperties(new ArrayList());
+ }
+ if (currentModel.getError() != null) {
+ currentModel.addProperty(model);
+ }
+ buildSourceInputProperties(listType, model, false, true,
+ resourceConfig, classLoader);
+ }
+ } else {
+ selector = selector.trim();
+ String[] properties = selector.split(SPACE_STRING);
+ if (properties != null) {
+ JavaBeanModel currentParent = currentModel;
+ for (int i = 0; i < properties.length; i++) {
+ String property = properties[i].trim();
+ Class currentClazz = currentParent.getBeanClass();
+ if (currentClazz != null
+ && property.equals(currentClazz.getName())) {
+
+ } else {
+ JavaBeanModel pm = findTheChildJavaBeanModel(property,
+ currentParent);
+ if (pm != null) {
+
+ } else {
+ pm = new JavaBeanModel(null, property);
+ pm.setProperties(new ArrayList());
+ pm.setError("don't exist");
+ currentParent.addProperty(pm);
+ }
+ currentParent = pm;
+ }
+ }
+ } else {
+ // if properties is null , how to process?
+ }
+ }
+ }
+
+ protected String getBeanIDFromParam(ResourceConfigType config) {
+ List list = config.getParam();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ ParamType p = (ParamType) iterator.next();
+ if ("beanId".equals(p.getName())) {
+ return SmooksModelUtils.getAnyTypeText(p);
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ * Find the child JavaBeanModel from parent with the child name <br>
+ * If the parent JavabeanModel is "Collection" or "Array" , the child
+ * JavabeanModel is the first child of the parent model,it means that the
+ * param "name" is useless with the status.<br>
+ *
+ * TODO The method need to improve!!!!!
+ *
+ * @param name
+ * @param parentModel
+ * @return
+ */
+ public static JavaBeanModel findTheChildJavaBeanModel(String name,
+ JavaBeanModel parentModel) {
+ List list = parentModel.getProperties();
+ if (list == null)
+ return null;
+ if (parentModel.isList() || parentModel.isArray()) {
+ if (list.size() >= 1 && parentModel.hasGenericType()) {
+ JavaBeanModel m = (JavaBeanModel) list.get(0);
+ return m;
+ }
+ }
+
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ if (name.equals(child.getName())) {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ public DesignTimeAnalyzeResult analyzeGraphModel(
+ SmooksConfigurationFileGenerateContext context) {
+ checkRootNodeConnected(context);
+ return checkOtherNodeConnected(context);
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.javabean.commandprocessor;
+
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.javabean.ui.JavaBeanModelCreationDialog;
+import org.jboss.tools.smooks.ui.gef.commandprocessor.ICommandProcessor;
+import org.jboss.tools.smooks.utils.UIUtils;
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 22, 2008
+ */
+public class JavaBeanModelCommandProcessor implements ICommandProcessor {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.ui.gef.commandprocessor.ICommandProcessor#getNewModel
+ * (java.lang.Object, java.lang.Object, org.eclipse.gef.GraphicalEditPart)
+ */
+ public Object getNewModel(CreateRequest request,
+ GraphicalEditPart rootEditPart) {
+ DefaultEditDomain domain = (DefaultEditDomain) ((GraphicalViewer) rootEditPart
+ .getViewer()).getEditDomain();
+ // rootEditPart.getg
+ IEditorPart editorPart = domain.getEditorPart();
+ Shell shell = editorPart.getSite().getShell();
+ JavaBeanModelCreationDialog dialog = new JavaBeanModelCreationDialog(
+ shell, UIUtils
+ .getJavaProjectFromEditorPart(editorPart));
+ if(dialog.open() == Window.OK){
+ return dialog.getCheckedJavaBeanModel();
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanContentProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanContentProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanContentProvider.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,52 @@
+package org.jboss.tools.smooks.javabean.model;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+/**
+ *
+ * @author Dart Peng
+ *
+ */
+public class BeanContentProvider implements ITreeContentProvider,
+ IStructuredContentProvider {
+
+ public Object[] getChildren(Object arg0) {
+ if (arg0 instanceof JavaBeanModel) {
+ return ((JavaBeanModel) arg0).getProperties().toArray();
+ }
+ return new Object[] {};
+ }
+
+ public Object getParent(Object arg0) {
+ if(arg0 instanceof JavaBeanModel){
+ return ((JavaBeanModel)arg0).getParent();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object bean) {
+ if (bean instanceof JavaBeanModel) {
+ return !((JavaBeanModel) bean).isPrimitive();
+ }
+ return false;
+ }
+
+ public Object[] getElements(Object arg0) {
+ if (arg0 instanceof List) {
+ return ((List) arg0).toArray();
+ }
+ return new Object[]{arg0};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanlabelProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanlabelProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanlabelProvider.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,68 @@
+package org.jboss.tools.smooks.javabean.model;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.javabean.ui.JavaImageConstants;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.utils.SmooksGraphConstants;
+
+public class BeanlabelProvider extends LabelProvider {
+
+ public Image getJavaObjectImage() {
+ return SmooksUIActivator.getDefault().getImageRegistry().get(
+ JavaImageConstants.IMAGE_JAVA_OBJECT);
+ }
+
+ public Image getJavaAttributeImage() {
+ return SmooksUIActivator.getDefault().getImageRegistry().get(
+ JavaImageConstants.IMAGE_JAVA_ATTRIBUTE);
+ }
+
+ public String getText(Object element) {
+ if (element instanceof JavaBeanModel) {
+ String name = ((JavaBeanModel) element).getName();
+ if (name == null)
+ name = "<nonamed>";
+
+ Object error = ((JavaBeanModel) element).getError();
+ if (error != null) {
+ name = name + " " + "<" + error.toString() + ">";
+ return name;
+ }
+
+ Class typeRef = ((JavaBeanModel) element).getBeanClass();
+ String typeStr = "";
+ if (typeRef != null) {
+ if (typeRef.isArray()) {
+ typeRef = typeRef.getComponentType();
+ typeStr = typeRef.getName() + "[]";
+ } else {
+ typeStr = typeRef.getName();
+ }
+ }
+ if (!typeStr.equals("")) {
+ name = name + " " + typeStr;
+ }
+
+ return name;
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof JavaBeanModel) {
+ Object error = ((JavaBeanModel) element).getError();
+ if (error != null) {
+ return SmooksUIActivator.getDefault().getImageRegistry().get(
+ SmooksGraphConstants.IMAGE_ERROR);
+ }
+ if (((JavaBeanModel) element).isPrimitive()) {
+ return this.getJavaAttributeImage();
+ } else {
+ return this.getJavaObjectImage();
+ }
+ }
+ return super.getImage(element);
+ }
+}
\ No newline at end of file
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/BeanlabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,373 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.javabean.model;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.tools.smooks.analyzer.IValidatable;
+import org.jboss.tools.smooks.javabean.uitils.JavaPropertyUtils;
+
+/**
+ * @author Dart Peng
+ *
+ */
+public class JavaBeanModel implements IValidatable {
+
+ private Object waring = null;
+
+ private Object error = null;
+
+ private String name = "";
+
+ private Class typeRef = null;
+
+ private boolean many = false;
+
+ private boolean collection = false;
+
+ private boolean isPrimitive = false;
+
+ private boolean hasGenericType = false;
+
+ private Class<? extends Object> beanClass = null;
+
+ private JavaBeanModel parent = null;
+
+ public Class getBeanClass() {
+ return beanClass;
+ }
+
+ private Class parentClass = null;
+
+ private boolean isRoot = false;
+
+ private boolean isRootClassModel = false;
+
+ /**
+ * @return the isRootClassModel
+ */
+ public boolean isRootClassModel() {
+ return isRootClassModel;
+ }
+
+ /**
+ * @param isRootClassModel
+ * the isRootClassModel to set
+ */
+ public void setRootClassModel(boolean isRootClassModel) {
+ this.isRootClassModel = isRootClassModel;
+ }
+
+ /**
+ * @return the isRoot
+ */
+ public boolean isRoot() {
+ return isRoot;
+ }
+
+ public String getBeanClassString() {
+ Class clazz = this.getBeanClass();
+ if (clazz == null)
+ return "<null>";
+
+ if (clazz.isArray()) {
+ String s = clazz.getComponentType().getName();
+ return s + "[]";
+ }
+
+ return clazz.getName();
+ }
+
+ /**
+ * @param isRoot
+ * the isRoot to set
+ */
+ public void setRoot(boolean isRoot) {
+ this.isRoot = isRoot;
+ }
+
+ private boolean isList = false;
+
+ private Class componentClass = null;
+
+ private boolean lazyLoadProperties = true;
+
+ public boolean isList() {
+ if(beanClass == null) return false;
+ if (Collection.class.isAssignableFrom(beanClass)) {
+ if (this.propertyDescriptor != null) {
+ Method rmethod = propertyDescriptor.getReadMethod();
+ if (rmethod != null) {
+ Type returnType = rmethod.getGenericReturnType();
+ if (returnType instanceof ParameterizedType) {
+ Type gtype = ((ParameterizedType) returnType)
+ .getActualTypeArguments()[0];
+ Class beanType = (Class) gtype;
+ componentClass = beanType;
+ setGenericType(true);
+ }
+ }
+ }
+ setList(true);
+ }
+ return isList;
+ }
+
+ public void setList(boolean isList) {
+ this.isList = isList;
+ }
+
+ private PropertyDescriptor propertyDescriptor;
+
+ public PropertyDescriptor getPropertyDescriptor() {
+ return propertyDescriptor;
+ }
+
+ public void setPropertyDescriptor(PropertyDescriptor propertyDescriptor) {
+ this.propertyDescriptor = propertyDescriptor;
+ }
+
+ JavaBeanModel(Class beanClass, String beanName,
+ PropertyDescriptor propertyDescriptor, Class parentClass,
+ boolean lazyLoadProperties) {
+ this.lazyLoadProperties = lazyLoadProperties;
+ this.beanClass = beanClass;
+ this.name = beanName;
+ if (beanClass == null)
+ return;
+ if(this.name == null){
+ this.name = beanClass.getSimpleName();
+ }
+
+
+ if (propertyDescriptor == null)
+ isRoot = true;
+ this.propertyDescriptor = propertyDescriptor;
+ Class beanType = beanClass;
+ if (beanClass.isArray()) {
+ beanType = beanClass.getComponentType();
+ setMany(true);
+ componentClass = beanType;
+ }
+
+ if (Collection.class.isAssignableFrom(beanClass)) {
+ if (this.propertyDescriptor != null) {
+ Method rmethod = propertyDescriptor.getReadMethod();
+ if (rmethod != null) {
+ Type returnType = rmethod.getGenericReturnType();
+ if (returnType instanceof ParameterizedType) {
+ Type gtype = ((ParameterizedType) returnType)
+ .getActualTypeArguments()[0];
+ beanType = (Class) gtype;
+ componentClass = beanType;
+ }
+ }
+ }
+ setList(true);
+ }
+
+ if (beanType.isPrimitive()
+ || JavaBeanModelFactory.isPrimitiveObject(beanType)) {
+ setTypeRef(beanType);
+ this.parentClass = parentClass;
+
+ if (!isArray() && !isList())
+ setPrimitive(true);
+ return;
+ }
+ this.parentClass = parentClass;
+
+ if (!lazyLoadProperties)
+ this.getProperties();
+ }
+
+ JavaBeanModel(Class beanClass, String beanName,
+ PropertyDescriptor propertyDescriptor) {
+ this(beanClass, beanName, propertyDescriptor, null, true);
+ }
+
+ public JavaBeanModel(Class beanClass) {
+ this(beanClass, null, null, null, true);
+ }
+
+ public JavaBeanModel(Class beanClass, String name) {
+ this(beanClass, name, null, null, true);
+ }
+
+ JavaBeanModel(Class beanClass, boolean lazyLoadProperties) {
+ this(beanClass, null, null, null, lazyLoadProperties);
+ }
+
+ public boolean isPrimitive() {
+ return isPrimitive;
+ }
+
+ public void setPrimitive(boolean isPrimitive) {
+ this.isPrimitive = isPrimitive;
+ }
+
+ public boolean isArray() {
+ if(beanClass == null) return false;
+ if (beanClass.isArray()) {
+ Class beanType = beanClass.getComponentType();
+ setMany(true);
+ componentClass = beanType;
+ setGenericType(true);
+ }
+ return many;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+ public boolean isCollection() {
+ return collection;
+ }
+
+ public void setCollection(boolean collection) {
+ this.collection = collection;
+ }
+
+ public Class getTypeRef() {
+ return typeRef;
+ }
+
+ public void setTypeRef(Class typeRef) {
+ this.typeRef = typeRef;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void addProperty(JavaBeanModel property) {
+ if (properties != null) {
+ properties.add(property);
+ property.setParent(this);
+ }
+ }
+
+ private List properties;
+
+ public List getProperties() {
+
+ if (properties == null) {
+ properties = new ArrayList();
+ Class beanType = beanClass;
+
+ if (this.componentClass != null) {
+ if (isArray() || isList()) {
+ JavaBeanModel proxyModel = new JavaBeanModel(
+ componentClass, componentClass.getSimpleName(),
+ null, beanClass, this.lazyLoadProperties);
+ beanType = componentClass;
+
+ addProperty(proxyModel);
+
+ return properties;
+ }
+ }
+ if(beanType == null) return null;
+ PropertyDescriptor[] pds = JavaPropertyUtils.getPropertyDescriptor(beanType);
+
+ for (int i = 0; i < pds.length; i++) {
+ PropertyDescriptor pd = pds[i];
+ if ("class".equals(pd.getName()))
+ continue;
+ JavaBeanModel jbm = new JavaBeanModel(pd.getPropertyType(), pd
+ .getName(), pd, beanClass, this.lazyLoadProperties);
+ addProperty(jbm);
+ }
+ }
+ return properties;
+ }
+
+ public void setProperties(List properties) {
+ this.properties = properties;
+ }
+
+ public boolean propertiesHasBeenLoaded() {
+ return properties != null;
+ }
+
+ /**
+ * @return the parent
+ */
+ public JavaBeanModel getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent
+ * the parent to set
+ */
+ public void setParent(JavaBeanModel parent) {
+ this.parent = parent;
+ }
+
+ public Object getWarning() {
+ return waring;
+ }
+
+ public void setWarning(Object waring) {
+ this.waring = waring;
+ }
+
+ public Object getError() {
+ return error;
+ }
+
+ public void setError(Object error) {
+ this.error = error;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer("JavaBean Name : " + name);
+ if (beanClass != null)
+ buffer.append(";Class : " + this.beanClass.getName());
+ if (this.properties != null) {
+ buffer.append("\n");
+ for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ buffer.append("\t");
+ buffer.append(child.toString());
+ buffer.append("\n");
+ }
+ }
+ return buffer.toString();
+ }
+
+ public boolean hasGenericType() {
+ return hasGenericType;
+ }
+
+ public void setGenericType(boolean hasGenericType) {
+ this.hasGenericType = hasGenericType;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.javabean.model;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author Dart Peng
+ *
+ */
+public class JavaBeanModelFactory {
+
+
+ private static final List PRIMITIVE_CLASSES = new ArrayList();
+ static{
+ PRIMITIVE_CLASSES.add(Integer.class);
+ PRIMITIVE_CLASSES.add(Double.class);
+ PRIMITIVE_CLASSES.add(Float.class);
+ PRIMITIVE_CLASSES.add(String.class);
+ PRIMITIVE_CLASSES.add(Long.class);
+ PRIMITIVE_CLASSES.add(java.util.Date.class);
+ PRIMITIVE_CLASSES.add(Character.class);
+ PRIMITIVE_CLASSES.add(BigInteger.class);
+ PRIMITIVE_CLASSES.add(BigDecimal.class);
+ PRIMITIVE_CLASSES.add(Byte.class);
+ }
+
+ /**
+ * @param beanClass
+ * @param modelName
+ * @return
+ */
+ public synchronized static JavaBeanModel getJavaBeanModelWithLazyLoad(Class beanClass ) {
+ JavaBeanModel m = new JavaBeanModel(beanClass,true);
+ m.setRootClassModel(true);
+ return m;
+ }
+
+ public synchronized static JavaBeanModel getJavaBeanModel(Class beanClass ) {
+ JavaBeanModel m = new JavaBeanModel(beanClass,false);
+ m.setRootClassModel(true);
+ return m;
+ }
+
+ public static boolean isPrimitiveObject(Class clazz) {
+ return (PRIMITIVE_CLASSES.indexOf(clazz) != -1);
+ }
+
+ public static void main(String[] args) throws SecurityException, NoSuchFieldException {
+// JavaBeanModel jbm = getJavaBeanModel(LineOrder.class);
+// System.out.println(jbm);
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanParser.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanParser.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanParser.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,38 @@
+package org.jboss.tools.smooks.javabean.model;
+
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
+import org.jboss.tools.smooks.ui.modelparser.IStructuredModelParser;
+
+/**
+ *
+ * @author Dart Peng
+ *
+ */
+public class JavaBeanParser implements IStructuredModelParser {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.ui.modelparser.IStructuredModelParser#parse(java
+ * .lang.Object)
+ */
+ public AbstractStructuredDataModel parse(Object customModel) {
+ if (customModel instanceof JavaBeanModel) {
+ AbstractStructuredDataModel model = null;
+ String name = ((JavaBeanModel) customModel).getName();
+
+ if (((JavaBeanModel) customModel).isRootClassModel()) {
+ model = new JavaStructuredDataModel();
+ ((JavaStructuredDataModel) model).setLabelName(name);
+ } else {
+ model = new JavabeanStructuredContentsModel();
+ ((JavabeanStructuredContentsModel) model).setName(name);
+ ((JavabeanStructuredContentsModel) model).setTypeString(((JavaBeanModel) customModel).getBeanClass().getName());
+ }
+ model.setReferenceEntityModel(customModel);
+ return model;
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaStructuredDataModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaStructuredDataModel.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaStructuredDataModel.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,6 @@
+package org.jboss.tools.smooks.javabean.model;
+
+import org.jboss.tools.smooks.ui.gef.model.StructuredDataModel;
+
+public class JavaStructuredDataModel extends StructuredDataModel {
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaStructuredDataModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavabeanStructuredContentsModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavabeanStructuredContentsModel.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavabeanStructuredContentsModel.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.javabean.model;
+
+import org.jboss.tools.smooks.ui.gef.model.StructuredDataContentModel;
+
+/**
+ * @author Dart Peng
+ *
+ */
+public class JavabeanStructuredContentsModel extends StructuredDataContentModel {
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.ui.gef.model.StructuredDataContentModel#getName()
+ */
+ @Override
+ public String getName() {
+ return super.getName();
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavabeanStructuredContentsModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.javabean.ui;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 21, 2008
+ */
+public class JavaBeanConfigWizardPage extends WizardPage implements
+ SelectionListener {
+
+ TreeViewer treeViewer;
+
+ Text classText = null;
+
+ Button classBrowseButton = null;
+
+ IJavaProject project = null;
+
+ private JavaBeanModelLoadComposite javaPropertySelectComposite;
+
+ public JavaBeanModel getJavaBeanModel(){
+ return javaPropertySelectComposite.getCheckedJavaBeanModel();
+ }
+
+ public JavaBeanConfigWizardPage(IJavaProject selection) {
+ super("beansearchwizardpage");
+ this.project = selection;
+ setPageComplete(true);
+ setTitle("JavaBean Class selection page");
+ setDescription("Select the JavaBean class");
+ }
+
+ protected void initilize() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ecSclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt
+ * .widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ initilize();
+// Composite cc = new Composite(parent,SWT.NONE);
+// cc.setLayout(new GridLayout());
+ try {
+ javaPropertySelectComposite = new JavaBeanModelLoadComposite(
+ parent, SWT.NONE, getContainer(), project);
+
+// Button button = new Button(cc, SWT.BORDER);
+//
+// final TreeViewer vi = new TreeViewer(cc, SWT.NONE);
+// GridData gd = new GridData(GridData.FILL_BOTH);
+// gd.grabExcessHorizontalSpace = true;
+// gd.grabExcessVerticalSpace = true;
+// vi.setContentProvider(new BeanContentProvider());
+// vi.setLabelProvider(new BeanlabelProvider());
+// vi.getTree().setLayoutData(gd);
+//
+// javaPropertySelectComposite.setLayoutData(gd);
+// button.addSelectionListener(new SelectionAdapter() {
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see
+// * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org
+// * .eclipse.swt.events.SelectionEvent)
+// */
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// // TODO Auto-generated method stub
+// super.widgetSelected(e);
+// List l = new ArrayList();
+// l.add(javaPropertySelectComposite.getCheckedJavaBeanModel());
+// vi.setInput(l);
+// }
+//
+// });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ this.setControl(javaPropertySelectComposite);
+ this.updatePage();
+ }
+
+ protected void updatePage() {
+ String error = null;
+ if (project == null) {
+ error = "Please select a Java project.";
+ }
+ setPageComplete(error == null);
+ this.setErrorMessage(error);
+ }
+
+// public JavaBeanConfigWizardPage(String pageName, String title,
+// ImageDescriptor titleImage) {
+// super(pageName, title, titleImage);
+// }
+
+ public JavaBeanConfigWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ widgetSelected(arg0);
+ }
+
+ public void widgetSelected(SelectionEvent arg0) {
+
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.javabean.ui;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 22, 2008
+ */
+public class JavaBeanModelCreationDialog extends TitleAreaDialog {
+
+ IJavaProject project = null;
+ private JavaBeanModelLoadComposite jc;
+
+ private JavaBeanModel returnModel;
+
+ /**
+ *
+ * @return
+ */
+ public JavaBeanModel getCheckedJavaBeanModel() {
+ return returnModel;
+ }
+
+ public JavaBeanModelCreationDialog(Shell parentShell, IJavaProject project) {
+ super(parentShell);
+ this.project = project;
+ }
+
+ public int open(){
+ return super.open();
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ returnModel = jc.getCheckedJavaBeanModel();
+ super.okPressed();
+// returnModel = jc.getCheckedJavaBeanModel();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse
+ * .swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Control area = super.createDialogArea(parent);
+ try {
+ this.createJavaBeanDialog(area, project);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return area;
+ }
+
+ /**
+ *
+ * @param area
+ * @param project
+ * @return
+ * @throws Exception
+ */
+ protected Control createJavaBeanDialog(Control area, IJavaProject project)
+ throws Exception {
+ jc = new JavaBeanModelLoadComposite((Composite) area, SWT.NONE, null,
+ project);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ jc.setLayoutData(gd);
+ gd.heightHint = 400;
+ return area;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelGraphUIProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelGraphUIProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelGraphUIProvider.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.javabean.ui;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Color;
+import org.jboss.tools.smooks.ui.gef.IGraphUIProvider;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class JavaBeanModelGraphUIProvider extends LabelProvider implements
+ IGraphUIProvider {
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.ui.gef.GraphLabelProvider#getBackgroundColor()
+ */
+ public Color getBackgroundColor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.ui.gef.GraphLabelProvider#getTypeText(java.lang.Object)
+ */
+ public String getTypeText(Object model) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelGraphUIProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.javabean.ui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
+import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModelFactory;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.utils.ProjectClassLoader;
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 22, 2008
+ */
+public class JavaBeanModelLoadComposite extends Composite implements
+ SelectionListener {
+
+ protected Text classText;
+ private Button classBrowseButton;
+ protected String classFullName;
+ protected boolean loadAtomic;
+ protected IJavaProject javaProject;
+ protected IRunnableContext runnableContext;
+ protected JavaBeanModel currentRootJavaBeanModel = null;
+ protected JavaBeanModel returnJavaBeanModel = null;
+
+ protected ProjectClassLoader loader = null;
+
+ public JavaBeanModelLoadComposite(Composite parent, int style,
+ IRunnableContext runnableContext, IJavaProject project,
+ boolean loadJavapropertiesAtomic) throws Exception {
+ super(parent, style);
+ loadAtomic = loadJavapropertiesAtomic;
+ this.runnableContext = runnableContext;
+ if (this.runnableContext == null) {
+ this.runnableContext = SmooksUIActivator.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow();
+ // this.runnableContext = new
+ // ProgressMonitorDialog(parent.getShell());
+ if (this.runnableContext == null)
+ throw new Exception("Can't init IRunnableContent");
+ }
+
+ if (project != null) {
+ javaProject = project;
+ loader = new ProjectClassLoader(javaProject);
+ }
+
+ createCompositeContent();
+ }
+
+ public JavaBeanModelLoadComposite(Composite parent, int style,
+ IRunnableContext runnableContext, IJavaProject project)
+ throws Exception {
+ this(parent, style, runnableContext, project, true);
+ }
+
+ protected Control createCompositeContent() {
+ Composite parent = this;
+ parent.setLayout(new FillLayout());
+ Composite com = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ com.setLayout(layout);
+
+ Label classLabel = new Label(com, SWT.NULL);
+ classLabel.setText("Class Name:");
+
+ Composite classTextContainer = new Composite(com, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ classTextContainer.setLayoutData(gd);
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ classTextContainer.setLayout(gl);
+
+ {
+ classText = new Text(classTextContainer, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ classText.setLayoutData(gd);
+ classText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent arg0) {
+ classFullName = classText.getText();
+ }
+ });
+
+ classBrowseButton = new Button(classTextContainer, SWT.NONE);
+ classBrowseButton.addSelectionListener(this);
+ classBrowseButton.setText("Browse...");
+ }
+ return com;
+ }
+
+ protected void recordModel() {
+ // this.currentRootJavaBeanModel.setProperties(null);
+ // this.fillCheckStateModel(this.currentRootJavaBeanModel);
+ }
+
+ protected void fillTheModelWithCheckStatus(JavaBeanModel javaBeanModel,
+ CheckboxTreeViewer viewer) {
+ ArrayList clist = new ArrayList();
+ if (javaBeanModel.propertiesHasBeenLoaded()) {
+ List children = javaBeanModel.getProperties();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ boolean checked = viewer.getChecked(child);
+ if (checked) {
+ clist.add(child);
+ fillTheModelWithCheckStatus(child, viewer);
+ }
+ }
+ }
+ javaBeanModel.setProperties(clist);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public JavaBeanModel getCheckedJavaBeanModel() {
+ return this.fillCheckStateModel(currentRootJavaBeanModel);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public JavaBeanModel fillCheckStateModel(JavaBeanModel rootJavaBean) {
+ if (rootJavaBean == null) {
+ // List list = (List) treeViewer.getInput();
+ // if (list != null)
+ // rootJavaBean = (JavaBeanModel) list.get(0);
+ try {
+ ProjectClassLoader loader = new ProjectClassLoader(javaProject);
+ Class clazz = loader.loadClass(this.classText.getText());
+ rootJavaBean = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(clazz);
+ } catch (Exception e) {
+
+ }
+ }
+ // if (rootJavaBean != null)
+ // this.fillTheModelWithCheckStatus(rootJavaBean, treeViewer);
+ return rootJavaBean;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ this.widgetSelected(arg0);
+
+ }
+
+ public void widgetSelected(SelectionEvent arg0) {
+ IJavaSearchScope scope = JavaSearchScopeFactory.getInstance()
+ .createJavaProjectSearchScope(javaProject, true);
+ SelectionDialog dialog;
+ try {
+ dialog = JavaUI.createTypeDialog(this.getShell(), runnableContext,
+ scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false);
+ dialog.setMessage("Source Java Bean:");
+ dialog.setTitle("Search java bean");
+
+ if (dialog.open() == Window.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length > 0) {
+ Object result = results[0];
+ String packageFullName = JavaModelUtil
+ .getTypeContainerName((IType) result);
+ if (packageFullName == null
+ || packageFullName.length() <= 0) {
+ classText.setText(((IType) result).getElementName());
+ } else {
+ classText.setText(packageFullName + "."
+ + ((IType) result).getElementName());
+ }
+ }
+ }
+ } catch (Exception e) {
+ // this.setErrorMessage("Error occurs!please see log file");
+ e.printStackTrace();
+ }
+
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaImageConstants.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaImageConstants.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaImageConstants.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,6 @@
+package org.jboss.tools.smooks.javabean.ui;
+
+public class JavaImageConstants {
+ public static final String IMAGE_JAVA_ATTRIBUTE = "java_attribute";
+ public static final String IMAGE_JAVA_OBJECT = "java_object";
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaImageConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.javabean.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.smooks.ui.IStructuredDataCreationWizard;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 5, 2008
+ */
+public class NewJavaBeanStrucutredDataWizard extends Wizard implements IStructuredDataCreationWizard,INewWizard{
+ JavaBeanConfigWizardPage page = null;
+ IJavaProject project = null;
+ Object result = null;
+ Properties properties = new Properties();
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ super.addPages();
+ if(page == null){
+ page = new JavaBeanConfigWizardPage(project);
+ this.addPage(page);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ result = page.getJavaBeanModel();
+ return true;
+ }
+
+ public Object getTreeViewerInputContents() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(result);
+ return list;
+ }
+
+ public void init(IEditorSite site, IEditorInput input) {
+ if(input != null && input instanceof IFileEditorInput){
+ IFileEditorInput fi = (IFileEditorInput)input;
+ IProject project = fi.getFile().getProject();
+ if(project instanceof IJavaProject){
+ this.project = (IJavaProject)project;
+ }else{
+ this.project = JavaCore.create(project);
+ }
+ }
+ }
+
+ public String getInputDataTypeID() {
+ return SmooksUIActivator.DATA_TYPE_ID_JAVABEAN;
+ }
+
+ public Properties getProperties() {
+ return this.properties;
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ if(selection != null){
+ Object obj = selection.getFirstElement();
+ if(obj instanceof JavaProject){
+ this.project = (JavaProject)obj;
+ }
+ if(obj instanceof IResource){
+ IProject project = ((IResource)obj).getProject();
+ this.project = JavaCore.create(project);
+ }
+
+ if(project == null){
+ if(obj instanceof IAdaptable){
+ IResource relateResource =(IResource) ((IAdaptable)obj).getAdapter(IResource.class);
+ IProject project = relateResource.getProject();
+ this.project = JavaCore.create(project);
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/uitils/JavaPropertyUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/uitils/JavaPropertyUtils.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/uitils/JavaPropertyUtils.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,45 @@
+package org.jboss.tools.smooks.javabean.uitils;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+
+/**
+ *
+ * @author Dart Peng<br>
+ * Date : Sep 10, 2008
+ */
+public class JavaPropertyUtils {
+
+ private static JavaPropertyUtils instace = null;
+
+ public static PropertyDescriptor[] getPropertyDescriptor(Class clazz) {
+ try {
+ return getInstace().getPropertyDescriptorArray(clazz);
+ } catch (Exception e) {
+ // ignore
+ return new PropertyDescriptor[]{};
+ }
+ }
+
+ /**
+ *
+ * @param clazz
+ * @return
+ * @throws IntrospectionException
+ */
+ public PropertyDescriptor[] getPropertyDescriptorArray(Class clazz)
+ throws IntrospectionException {
+ // TODO should improve (use some catch to store the BeanInfo , right?)
+ return Introspector
+ .getBeanInfo(clazz, Introspector.IGNORE_ALL_BEANINFO)
+ .getPropertyDescriptors();
+ }
+
+ public static JavaPropertyUtils getInstace() {
+ if (instace == null) {
+ instace = new JavaPropertyUtils();
+ }
+ return instace;
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/uitils/JavaPropertyUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java 2008-10-20 10:08:30 UTC (rev 10973)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -4,7 +4,9 @@
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.smooks.javabean.ui.JavaImageConstants;
import org.jboss.tools.smooks.utils.SmooksGraphConstants;
+import org.jboss.tools.smooks.xml.XMLImageConstants;
import org.osgi.framework.BundleContext;
/**
@@ -14,7 +16,15 @@
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.smooks.ui";
+
+ public static final String TYPE_ID_XSD = "org.jboss.tools.smooks.xml.viewerInitor.xsd";
+
+ public static final String TYPE_ID_XML = "org.jboss.tools.smooks.xml.viewerInitor.xml";
+
+ public static final String DATA_TYPE_ID_JAVABEAN = "org.jboss.tools.smooks.ui.viewerInitor.javabean";
+
+
// The shared instance
private static SmooksUIActivator plugin;
@@ -48,6 +58,16 @@
reg.put(SmooksGraphConstants.IMAGE_EMPTY, getImageDescriptor(SmooksGraphConstants.IMAGE_PATH_BLANK));
reg.put(SmooksGraphConstants.IMAGE_ERROR, getImageDescriptor(SmooksGraphConstants.IMAGE_PATH_ERROR));
reg.put(SmooksGraphConstants.IMAGE_WARNING, getImageDescriptor(SmooksGraphConstants.IMAGE_PATH_WARNING));
+ reg.put(XMLImageConstants.IMAGE_XML_ATTRIBUTE,
+ imageDescriptorFromPlugin(PLUGIN_ID,
+ "icons/full/obj16/attribute_obj.gif"));
+ reg.put(XMLImageConstants.IMAGE_XML_ELEMENT,
+ imageDescriptorFromPlugin(PLUGIN_ID,
+ "icons/full/obj16/element_obj.gif"));
+ reg.put(JavaImageConstants.IMAGE_JAVA_ATTRIBUTE,
+ imageDescriptorFromPlugin(PLUGIN_ID, "icons/full/obj16/att_obj.gif"));
+ reg.put(JavaImageConstants.IMAGE_JAVA_OBJECT,
+ imageDescriptorFromPlugin(PLUGIN_ID, "icons/full/obj16/class_obj.gif"));
}
/**
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,328 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml;
+
+import java.io.File;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.INewWizard;
+
+/**
+ *
+ * @author Dart Peng Date : 2008-8-13
+ */
+public abstract class AbstractFileSelectionWizardPage extends WizardPage
+ implements SelectionListener {
+ protected IStructuredSelection selection;
+ protected Object returnObject = null;
+ protected Text fileText;
+ protected Composite fileTextComposite;
+ protected CheckboxTableViewer tableViewer = null;
+ protected Button fileSystemBrowseButton;
+ protected boolean reasourceLoaded = false;
+ private Button workspaceBrowseButton;
+
+ public AbstractFileSelectionWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+ public Object getReturnValue() {
+ try {
+ returnObject = this.loadedTheObject(fileText.getText());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return returnObject;
+ }
+
+ public String getFilePath(){
+ return fileText.getText();
+ }
+ /*
+ * (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 layout = new GridLayout();
+ layout.numColumns = 1;
+ mainComposite.setLayout(layout);
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ mainComposite.setLayoutData(gd);
+
+ // xmlButton = new Button(mainComposite, SWT.RADIO);
+ // xmlButton.setText("Select a XML file");
+ //
+ // Composite xmlComposite = this
+ // .createXMLFileSelectionComposite(mainComposite);
+ //
+ // Label sp = new Label(mainComposite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ // gd = new GridData(GridData.FILL_HORIZONTAL);
+ // sp.setLayoutData(gd);
+ //
+ // xsdButton = new Button(mainComposite, SWT.RADIO);
+ // xsdButton.setText("Select a XSD file");
+
+ Composite xsdComposite = this
+ .createFileSelectionComposite(mainComposite);
+
+ // init the panel status (XSD file selection composite is disabled)
+ // xsdButton.setSelection(true);
+ //
+ // setCompositeChildrenEnabled(xmlComposite, false);
+
+ // registe the listener for controls
+ hookBrowseButtonSelectionAdapter();
+ hookFileTextModifyListener();
+ this.setControl(mainComposite);
+ }
+
+ protected void hookFileTextModifyListener() {
+ final ModifyListener modifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ changeWizardPageStatus();
+ }
+ };
+ // xmlFileText.addModifyListener(modifyListener);
+ fileText.addModifyListener(modifyListener);
+ }
+
+ protected void hookRadioButtonSelectionAdapter() {
+ // xsdButton.addSelectionListener(this);
+ }
+
+ protected void hookBrowseButtonSelectionAdapter() {
+ SelectionAdapter browseButtonSelectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Text relationT = null;
+ if (e.getSource() == fileSystemBrowseButton) {
+ relationT = fileText;
+ }
+ openFileSelection(relationT);
+ }
+ };
+ SelectionAdapter wbrowseButtonSelectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Text relationT = null;
+ if (e.getSource() == workspaceBrowseButton) {
+ relationT = fileText;
+ }
+ openWorkSpaceSelection(relationT);
+ }
+
+ };
+
+ workspaceBrowseButton
+ .addSelectionListener(wbrowseButtonSelectionAdapter);
+ // xmlFileSystemBrowseButton
+ // .addSelectionListener(browseButtonSelectionAdapter);
+ fileSystemBrowseButton
+ .addSelectionListener(browseButtonSelectionAdapter);
+ }
+
+ protected void openWorkSpaceSelection(Text relationT) {
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(),
+ "", "", false, null, Collections.EMPTY_LIST);
+ // dialog.setInitialSelections(selectedResources);
+ if (files.length > 0) {
+ IFile file = files[0];
+ String s = file.getLocation().toOSString();
+ relationT.setText(s);
+ }
+ }
+
+ protected Composite createFileSelectionComposite(Composite parent) {
+ Composite xsdComposite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ xsdComposite.setLayoutData(gd);
+ GridLayout xsdLayout = new GridLayout();
+ xsdLayout.numColumns = 2;
+ xsdLayout.marginWidth = 0;
+ xsdComposite.setLayout(xsdLayout);
+
+ Label nfileLanel = new Label(xsdComposite, SWT.NONE);
+ nfileLanel.setText("XML File Path :");
+ fileTextComposite = new Composite(xsdComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ fileTextComposite.setLayoutData(gd);
+ GridLayout xsdtgl = new GridLayout();
+ xsdtgl.marginWidth = 0;
+ xsdtgl.marginHeight = 0;
+ xsdtgl.numColumns = 1;
+ fileTextComposite.setLayout(xsdtgl);
+
+ fileText = new Text(fileTextComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ gd.grabExcessHorizontalSpace = true;
+
+// final Button loadXSDButton = new Button(fileTextComposite, SWT.NONE);
+// loadXSDButton.setText("Load");
+// loadXSDButton.addSelectionListener(new SelectionAdapter() {
+//
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// super.widgetSelected(e);
+// reasourceLoaded = false;
+// try {
+// returnObject = loadedTheObject(fileText.getText());
+// reasourceLoaded = true;
+// } catch (Throwable e2) {
+// // ignore
+// e2.printStackTrace();
+// }
+// changeWizardPageStatus();
+// }
+//
+// });
+
+ Composite browseButtonComposite = new Composite(xsdComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ browseButtonComposite.setLayoutData(gd);
+
+ GridLayout bg = new GridLayout();
+ bg.numColumns = 2;
+ bg.marginHeight = 0;
+ bg.marginWidth = 0;
+ bg.makeColumnsEqualWidth = false;
+ browseButtonComposite.setLayout(bg);
+
+ fileSystemBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ fileSystemBrowseButton.setText("Browse File System...");
+
+ workspaceBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ workspaceBrowseButton.setText("Browse workspace file..");
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.END;
+ workspaceBrowseButton.setLayoutData(gd);
+
+ gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.END;
+ fileSystemBrowseButton.setLayoutData(gd);
+
+ return xsdComposite;
+ }
+
+ abstract protected Object loadedTheObject(String path) throws Exception;
+
+ protected void initTableViewer() {
+// tableViewer.addCheckStateListener(new ICheckStateListener() {
+// boolean flag = true;
+//
+// public void checkStateChanged(CheckStateChangedEvent event) {
+// if (flag) {
+// Object checkObject = event.getElement();
+// boolean check = event.getChecked();
+// flag = false;
+// tableViewer.setAllChecked(false);
+// tableViewer.setChecked(checkObject, check);
+// flag = true;
+// changeWizardPageStatus();
+// }
+// }
+// });
+// tableViewer.setContentProvider(new XSDStructuredModelContentProvider());
+// tableViewer.setLabelProvider(new XSDStructuredModelLabelProvider());
+ }
+
+ protected void setCompositeChildrenEnabled(Composite composite,
+ boolean enabled) {
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (child instanceof Text) {
+ child.setEnabled(enabled);
+ }
+ if (child instanceof Button) {
+ child.setEnabled(enabled);
+ }
+ if (child instanceof Composite) {
+ setCompositeChildrenEnabled((Composite) child, enabled);
+ }
+ }
+ }
+
+ protected void openFileSelection(Text relationText) {
+ FileDialog dialog = new FileDialog(this.getShell());
+ String path = dialog.open();
+ if (path != null) {
+ relationText.setText(path);
+ }
+ }
+
+ protected void changeWizardPageStatus() {
+ String text = this.fileText.getText();
+ String error = null;
+ if (text == null || "".equals(text))
+ error = "Please Select a file";
+
+ File tempFile = new File(text);
+ if(!tempFile.exists()){
+ error = "Can't find the file , please select another one.";
+ }
+
+// if (!reasourceLoaded) {
+// error = "Resource must be loaded";
+// }
+ this.setErrorMessage(error);
+ this.setPageComplete(error == null);
+
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ changeWizardPageStatus();
+ }
+
+ public CheckboxTableViewer getTableViewer() {
+ return tableViewer;
+ }
+
+ public void setTableViewer(CheckboxTableViewer tableViewer) {
+ this.tableViewer = tableViewer;
+ }
+
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ public void setSelection(IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,70 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.smooks.ui.IStructuredDataCreationWizard;
+
+/**
+ * @author Dart
+ *
+ */
+public abstract class AbstractStructuredDdataWizard extends Wizard implements
+ IStructuredDataCreationWizard ,INewWizard{
+ protected IWorkbench workbench;
+
+ protected IStructuredSelection selection;
+
+ protected AbstractFileSelectionWizardPage page = null;
+ protected Object xsdElement = null;
+ protected IWizardNode strucutredDataCreationWizardNode;
+ /**
+ *
+ */
+ public AbstractStructuredDdataWizard() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void addPages() {
+ if(page == null){
+ page = createAbstractFileSelectionWizardPage();
+ page.setSelection(this.selection);
+ }
+ this.addPage(page);
+ }
+
+ abstract protected AbstractFileSelectionWizardPage createAbstractFileSelectionWizardPage() ;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ xsdElement = this.page.getReturnValue();
+ return true;
+ }
+ public Object getTreeViewerInputContents() {
+ return xsdElement;
+ }
+
+ public void init(IEditorSite site, IEditorInput input) {
+
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ }
+
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/XMLImageConstants.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/XMLImageConstants.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/XMLImageConstants.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,14 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml;
+
+/**
+ * @author Dart Peng
+ * Date : 2008-8-21
+ */
+public class XMLImageConstants {
+ public static final String IMAGE_XML_ELEMENT = "xml_element";
+
+ public static final String IMAGE_XML_ATTRIBUTE = "xml_attribute";
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/XMLImageConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.xml.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class AbstractXMLObject {
+
+ protected AbstractXMLObject parent;
+
+ protected String name;
+
+ protected List<AbstractXMLObject> children = new ArrayList<AbstractXMLObject>();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<AbstractXMLObject> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<AbstractXMLObject> children) {
+ this.children = children;
+ }
+
+ /**
+ * @return the parent
+ */
+ public AbstractXMLObject getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent the parent to set
+ */
+ public void setParent(AbstractXMLObject parent) {
+ this.parent = parent;
+ }
+
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/DocumentObject.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/DocumentObject.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/DocumentObject.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.xml.model;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 26, 2008
+ */
+public class DocumentObject extends AbstractXMLObject {
+ TagObject rootTag;
+
+ public TagObject getRootTag() {
+ return rootTag;
+ }
+
+ public void setRootTag(TagObject rootTag) {
+ this.rootTag = rootTag;
+ if(rootTag != null) rootTag.setParent(this);
+ }
+
+ public String toString(){
+ if(rootTag != null)
+ return "Document : " + getName() + "\n" + getRootTag().toString();
+
+ return "Docuement Object : " +getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.xml.model.AbstractXMLObject#getParent()
+ */
+ @Override
+ public AbstractXMLObject getParent() {
+ return null;
+ }
+
+
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/DocumentObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.xml.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class TagObject extends AbstractXMLObject {
+ protected List<TagPropertyObject> properties = new ArrayList<TagPropertyObject>();
+
+ public List<TagPropertyObject> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List<TagPropertyObject> properties) {
+ this.properties = properties;
+ }
+
+ public void addProperty(TagPropertyObject pro) {
+ this.getProperties().add(pro);
+ if (pro != null)
+ pro.setParent(this);
+ }
+
+ public void removeProperty(TagPropertyObject pro) {
+ this.getProperties().remove(pro);
+ if (pro != null)
+ pro.setParent(null);
+ }
+
+ public void addChildTag(TagObject tag) {
+ this.getChildren().add(tag);
+ if (tag != null)
+ tag.setParent(this);
+ }
+
+ public void removeChildTag(TagObject tag) {
+ this.getChildren().remove(tag);
+ if (tag != null)
+ tag.setParent(null);
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(getName());
+ buffer.append("\n");
+ for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
+ TagPropertyObject pro = (TagPropertyObject) iterator.next();
+ buffer.append("\t");
+ buffer.append(pro.getName());
+ buffer.append("\n");
+ }
+
+ List l = getChildren();
+ for (Iterator iterator = l.iterator(); iterator.hasNext();) {
+ TagObject tag = (TagObject) iterator.next();
+ buffer.append("\t");
+ buffer.append(tag.toString());
+ buffer.append("\n");
+ }
+ return buffer.toString();
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.xml.model;
+
+import java.util.List;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class TagPropertyObject extends AbstractXMLObject {
+
+ protected String type = "string";
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public List<AbstractXMLObject> getChildren() {
+ return null;
+ }
+ @Override
+ public void setChildren(List<AbstractXMLObject> children) {
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.xml.model;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class XMLObjectAnalyzer {
+ public DocumentObject analyze(String xmlFilePath)
+ throws FileNotFoundException, DocumentException {
+ FileInputStream stream = new FileInputStream(xmlFilePath);
+ return this.analyze(stream);
+ }
+
+ public DocumentObject analyze(InputStream stream) throws DocumentException {
+ SAXReader reader = new SAXReader();
+ Document doc = reader.read(stream);
+ Element rootElement = doc.getRootElement();
+ DocumentObject dco = new DocumentObject();
+ dco.setName("Docuement");
+ dco.setRootTag( parseElement(rootElement, null));
+ return dco;
+ }
+
+ protected TagObject getChildTagByName(String name, TagObject tag) {
+ if (tag == null)
+ return null;
+ List list = tag.getChildren();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ TagObject tagc = (TagObject) iterator.next();
+ if (tagc.getName().equals(name))
+ return tagc;
+ }
+ return null;
+ }
+
+ protected TagObject parseElement(Element element, TagObject parentTag) {
+ boolean canAdd = false;
+ TagObject tag = getChildTagByName(element.getName(), parentTag);
+ if (tag == null) {
+ tag = new TagObject();
+ canAdd = true;
+ }
+ tag.setName(element.getName());
+ fillProperties(element, tag);
+
+ List list = element.elements();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ Element childElement = (Element) iterator.next();
+ TagObject t = parseElement(childElement, tag);
+ if (t != null)
+ tag.addChildTag(t);
+ }
+ if (canAdd)
+ return tag;
+ else
+ return null;
+ }
+
+ protected boolean hasSameNameProperty(String proName, TagObject tag) {
+ List pros = tag.getProperties();
+ for (Iterator iterator = pros.iterator(); iterator.hasNext();) {
+ TagPropertyObject tp = (TagPropertyObject) iterator.next();
+ if (tp.getName().equals(proName))
+ return true;
+ }
+ return false;
+ }
+
+ protected void fillProperties(Element element, TagObject tag) {
+ Iterator it = element.attributeIterator();
+ for (Iterator iterator = it; iterator.hasNext();) {
+ Attribute attr = (Attribute) iterator.next();
+ if (hasSameNameProperty(attr.getName(), tag)) {
+ continue;
+ }
+ TagPropertyObject pro = new TagPropertyObject();
+ pro.setName(attr.getName());
+
+ tag.addProperty(pro);
+ }
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStructuredModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStructuredModel.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStructuredModel.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.xml.model;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 24, 2008
+ */
+public class XMLStructuredModel implements IAdaptable {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStructuredModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStrucutredModelParser.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStrucutredModelParser.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStrucutredModelParser.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.xml.model;
+
+import org.eclipse.xsd.XSDAttributeDeclaration;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+import org.eclipse.xsd.XSDTypeDefinition;
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
+import org.jboss.tools.smooks.ui.gef.model.StructuredDataContentModel;
+import org.jboss.tools.smooks.ui.gef.model.StructuredDataModel;
+import org.jboss.tools.smooks.ui.modelparser.IStructuredModelParser;
+
+/**
+ *
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class XMLStrucutredModelParser implements IStructuredModelParser {
+
+ public AbstractStructuredDataModel parse(Object customModel) {
+ AbstractStructuredDataModel model = null;
+ // for AbstractXMLObject (come from xml file fragment)
+ if(customModel instanceof DocumentObject){
+ model = new StructuredDataModel();
+ model.setLabelName(((DocumentObject)customModel).getName());
+ }
+
+ if(customModel instanceof TagObject){
+ model = new StructuredDataContentModel();
+ model.setLabelName(((TagObject)customModel).getName());
+ }
+ if(customModel instanceof TagPropertyObject){
+ model = new StructuredDataContentModel();
+ model.setLabelName(((TagPropertyObject)customModel).getName());
+ model.setTypeString(((TagPropertyObject)customModel).getType());
+ }
+
+ // for XSD (come from XML Schema file)
+ if (customModel instanceof XSDSchema) {
+ model = new StructuredDataModel();
+ StructuredDataModel sm = (StructuredDataModel) model;
+ sm.setLabelName("Schema");
+ }
+ if (customModel instanceof XSDElementDeclaration) {
+ model = new StructuredDataContentModel();
+ model.setLabelName(((XSDElementDeclaration) customModel)
+ .getAliasName());
+ model
+ .setTypeString(getElementTypeString((XSDElementDeclaration) customModel));
+ }
+ if (customModel instanceof XSDAttributeDeclaration) {
+ model = new StructuredDataContentModel();
+ model.setLabelName(((XSDAttributeDeclaration) customModel)
+ .getAliasName());
+ model.setTypeString(((XSDAttributeDeclaration) customModel)
+ .getTypeDefinition().getQName());
+ }
+ if (model != null) {
+ model.setReferenceEntityModel(customModel);
+ }
+ return model;
+ }
+
+ protected boolean isSimpleElement(XSDElementDeclaration element) {
+ return this.getSimpleType(element) != null;
+ }
+
+ protected String getElementTypeString(XSDElementDeclaration element) {
+ if (isSimpleElement(element)) {
+ XSDSimpleTypeDefinition simple = getSimpleType(element);
+ return simple.getQName();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ * @param element
+ * @return
+ */
+ protected XSDSimpleTypeDefinition getSimpleType(
+ XSDElementDeclaration element) {
+ XSDTypeDefinition type = element.getType();
+ return type.getSimpleType();
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLStrucutredModelParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.xml.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
+import org.jboss.tools.smooks.xml.model.DocumentObject;
+import org.jboss.tools.smooks.xml.model.TagObject;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 18, 2008
+ */
+public class XMLStructuredDataContentProvider implements ITreeContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object obj) {
+ // for AbstractXMLObject (come from xml file fragment)
+ if(obj instanceof DocumentObject){
+ return new Object[]{((DocumentObject)obj).getRootTag()};
+ }
+
+ if(obj instanceof TagObject){
+ List c = new ArrayList();
+ List pros = ((TagObject)obj).getProperties();
+ c.addAll(pros);
+ c.addAll(((TagObject)obj).getChildren());
+
+ return c.toArray();
+ }
+ return new Object[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object )
+ */
+ public Object getParent(Object arg0) {
+ if(arg0 instanceof AbstractXMLObject){
+ return ((AbstractXMLObject)arg0).getParent();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
+ * Object)
+ */
+ public boolean hasChildren(Object obj) {
+
+ // for AbstractXMLObject (come from xml file fragment)
+ if(obj instanceof DocumentObject){
+ return true;
+ }
+ if(obj instanceof TagObject){
+ List pros = ((TagObject)obj).getProperties();
+ List c = (((TagObject)obj).getChildren());
+ return !pros.isEmpty() || !c.isEmpty();
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java
+ * .lang.Object)
+ */
+ public Object[] getElements(Object arg0) {
+ if (arg0 instanceof List) {
+ return ((List) arg0).toArray();
+ }
+ if(arg0 instanceof DocumentObject){
+ return new Object[]{((DocumentObject)arg0).getRootTag()};
+ }
+ return new Object[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface
+ * .viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+ }
+
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataLabelProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataLabelProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataLabelProvider.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.xml.ui;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.xml.XMLImageConstants;
+import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
+import org.jboss.tools.smooks.xml.model.DocumentObject;
+import org.jboss.tools.smooks.xml.model.TagObject;
+import org.jboss.tools.smooks.xml.model.TagPropertyObject;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 18, 2008
+ */
+public class XMLStructuredDataLabelProvider extends LabelProvider {
+
+ public Image getXmlElementImage() {
+ return SmooksUIActivator.getDefault().getImageRegistry().get(
+ XMLImageConstants.IMAGE_XML_ELEMENT);
+
+ }
+
+ public Image getXmlAttributeImage() {
+ return SmooksUIActivator.getDefault().getImageRegistry().get(
+ XMLImageConstants.IMAGE_XML_ATTRIBUTE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof TagObject) {
+ return getXmlElementImage();
+ }
+ if (element instanceof TagPropertyObject) {
+ return getXmlAttributeImage();
+ }
+ return super.getImage(element);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ if (element instanceof DocumentObject) {
+ return "Root";
+ }
+ if (element instanceof AbstractXMLObject) {
+ return ((AbstractXMLObject) element).getName();
+ }
+ return super.getText(element);
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.xml.ui;
+
+import java.util.Properties;
+
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.xml.AbstractFileSelectionWizardPage;
+import org.jboss.tools.smooks.xml.AbstractStructuredDdataWizard;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 18, 2008
+ */
+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");
+ }
+
+ 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 SmooksUIActivator.TYPE_ID_XML;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,39 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml.ui;
+
+import org.jboss.tools.smooks.xml.AbstractFileSelectionWizardPage;
+import org.jboss.tools.smooks.xml.model.DocumentObject;
+import org.jboss.tools.smooks.xml.model.XMLObjectAnalyzer;
+
+/**
+ * @author Dart Peng Date : 2008-8-16
+ */
+public class XMLStructuredDataWizardPage extends
+ AbstractFileSelectionWizardPage {
+
+
+ public XMLStructuredDataWizardPage(String pageName) {
+ super(pageName);
+ setPageText();
+ }
+
+ private void setPageText() {
+ this.setTitle("Select xml file");
+ this.setDescription("Select a .xml file to be the source/target data");
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.xml.ui.AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
+ */
+ @Override
+ protected Object loadedTheObject(String path) throws Exception {
+ XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
+ DocumentObject doc = analyzer.analyze(path);
+ return doc;
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,400 @@
+/*******************************************************************************
+ * 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.xml2java.analyzer;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.text.html.HTMLDocument.HTMLReader.TagAction;
+
+import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.jboss.tools.smooks.analyzer.AbstractAnalyzer;
+import org.jboss.tools.smooks.analyzer.DesignTimeAnalyzeResult;
+import org.jboss.tools.smooks.analyzer.MappingModel;
+import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
+import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
+import org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.model.ParamType;
+import org.jboss.tools.smooks.model.ResourceConfigType;
+import org.jboss.tools.smooks.model.ResourceType;
+import org.jboss.tools.smooks.model.SmooksFactory;
+import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.model.util.SmooksModelConstants;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
+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.SourceModel;
+import org.jboss.tools.smooks.ui.gef.model.TreeItemRelationModel;
+import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+import org.jboss.tools.smooks.utils.UIUtils;
+import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
+import org.jboss.tools.smooks.xml.model.DocumentObject;
+import org.jboss.tools.smooks.xml.model.TagObject;
+import org.jboss.tools.smooks.xml.model.TagPropertyObject;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 20, 2008
+ */
+public class XML2JavaAnalyzer extends AbstractAnalyzer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.analyzer.IAnalyzer#analyzeMappingGraphModel(org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext)
+ */
+ public void analyzeMappingGraphModel(
+ SmooksConfigurationFileGenerateContext context)
+ throws SmooksAnalyzerException {
+
+ SmooksResourceListType listType = context.getSmooksResourceListModel();
+ GraphRootModel rootModel = context.getGraphicalRootModel();
+ List children = rootModel.getChildren();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ TreeItemRelationModel dataModel = (TreeItemRelationModel) iterator
+ .next();
+ if (dataModel.getClass() == SourceModel.class) {
+ List sourceConnections = dataModel.getModelSourceConnections();
+ if (sourceConnections.isEmpty())
+ continue;
+ processSourceConnections(sourceConnections, context, listType,
+ (SourceModel) dataModel);
+ }
+ }
+ }
+
+ protected void processSourceConnections(List sourceConnections,
+ SmooksConfigurationFileGenerateContext context,
+ SmooksResourceListType listType, SourceModel sourceModel) {
+ for (Iterator iterator = sourceConnections.iterator(); iterator
+ .hasNext();) {
+ LineConnectionModel connection = (LineConnectionModel) iterator
+ .next();
+ processLineConnection(connection, context, listType, sourceModel,
+ null);
+ }
+ }
+
+ protected void processLineConnection(LineConnectionModel connection,
+ SmooksConfigurationFileGenerateContext context,
+ SmooksResourceListType listType, SourceModel sourceModel,
+ String beanID) {
+ if (this.connectionIsUsed(connection))
+ return;
+ setConnectionUsed(connection);
+ IConnectableModel sourceg = connection.getSource();
+ if (sourceg != sourceModel)
+ return;
+ IConnectableModel targetg = connection.getTarget();
+ AbstractXMLObject source = (AbstractXMLObject) sourceModel
+ .getReferenceEntityModel();
+ JavaBeanModel target = (JavaBeanModel) ((AbstractStructuredDataModel) targetg)
+ .getReferenceEntityModel();
+ ResourceConfigType resourceConfigType = SmooksFactory.eINSTANCE
+ .createResourceConfigType();
+ context.getGeneratorResourceList().add(resourceConfigType);
+ // addResourceConfigType(listType, resourceConfigType);
+ // set the selector string value
+ resourceConfigType.setSelector(source.getName());
+ // create a resource and add it to resourceConfig
+ ResourceType resourceType = SmooksFactory.eINSTANCE
+ .createResourceType();
+ resourceType.setValue(SmooksModelConstants.BEAN_POPULATOR);
+ resourceConfigType.setResource(resourceType);
+
+ // create param for resourceConfig
+ if (beanID == null) {
+ beanID = getBeanID(target);
+ } else {
+ if (beanID.startsWith("${") && beanID.endsWith("}")) {
+ beanID = beanID.substring(2, beanID.length() - 1);
+ }
+ }
+
+ addParamTypeToResourceConfig(resourceConfigType,
+ SmooksModelConstants.BEAN_ID, beanID);
+
+ // add beanClass param
+ addParamTypeToResourceConfig(resourceConfigType,
+ SmooksModelConstants.BEAN_CLASS, target.getBeanClassString());
+
+ // add bindings param
+ ParamType bindingsParam = addParamTypeToResourceConfig(
+ resourceConfigType, SmooksModelConstants.BINDINGS, null);
+ processBindingsParam(bindingsParam, target, source, context, listType);
+ //
+ }
+
+ protected void processBindingsParam(ParamType bindingsParam,
+ JavaBeanModel javaBean, AbstractXMLObject source,
+ SmooksConfigurationFileGenerateContext context,
+ SmooksResourceListType listType) {
+ List properties = javaBean.getProperties();
+ for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
+ boolean isComplex = true;
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ AbstractStructuredDataModel graphModel = UIUtils.findGraphModel(
+ context.getGraphicalRootModel(), child);
+ LineConnectionModel connection = UIUtils
+ .getFirstTargetModelViaConnection(graphModel);
+ if (connection == null)
+ continue;
+ AbstractStructuredDataModel sourceModel = (AbstractStructuredDataModel) connection
+ .getSource();
+
+ if (child.isPrimitive() || child.getProperties().isEmpty()) {
+ isComplex = false;
+ }
+
+ String selector = getSelectorID(child);
+ if (!isComplex) {
+ selector = getSelectorIDViaXMLObject(
+ (AbstractXMLObject) sourceModel
+ .getReferenceEntityModel(), source);
+ }
+ SmooksModelUtils.addBindingTypeToParamType(bindingsParam, child
+ .getName(), selector, null, null);
+ if (isComplex) {
+ processLineConnection(connection, context, listType,
+ (SourceModel) sourceModel, selector);
+ } else {
+ setConnectionUsed(connection);
+ continue;
+ }
+ }
+ }
+
+ protected String getSelectorIDViaXMLObject(AbstractXMLObject sourceModel,
+ AbstractXMLObject currentRoot) {
+ String name = sourceModel.getName();
+ if (sourceModel instanceof TagPropertyObject) {
+ name = "@" + name;
+ }
+ AbstractXMLObject parent = sourceModel.getParent();
+ while (parent != null && parent.getName() != null) {
+ name = parent.getName() + " " + name;
+ if (parent == currentRoot)
+ break;
+ parent = parent.getParent();
+ }
+ return name;
+ }
+
+ private String getSelectorID(JavaBeanModel javaBean) {
+ String selectorName = javaBean.getName();
+ return "${" + selectorName + "}";
+ }
+
+ protected String getBeanID(JavaBeanModel target) {
+ return target.getName();
+ }
+
+ public MappingResourceConfigList analyzeMappingSmooksModel(
+ SmooksResourceListType listType, Object sourceObject,
+ Object targetObject) {
+ if(sourceObject instanceof DocumentObject){
+ sourceObject = ((DocumentObject)sourceObject).getRootTag();
+ }
+ if(targetObject instanceof List){
+ targetObject = (JavaBeanModel) ((List)targetObject).get(0);
+ }
+ if (!(sourceObject instanceof AbstractXMLObject)
+ || !(targetObject instanceof JavaBeanModel)) {
+ return MappingResourceConfigList.createEmptyList();
+ }
+ AbstractXMLObject sourceRoot = (AbstractXMLObject) sourceObject;
+ JavaBeanModel sourceTarget = (JavaBeanModel) targetObject;
+
+ ResourceConfigType rootResourceConfig = findFirstMappingResourceConfig(listType);
+ String xmlName = rootResourceConfig.getSelector();
+ AbstractXMLObject source = findXMLObjectByName(xmlName, sourceRoot);
+ if (source == null)
+ return MappingResourceConfigList.createEmptyList();
+
+ MappingResourceConfigList rcl = new MappingResourceConfigList();
+ this.createMappingResourceConfigList(rcl, listType, rootResourceConfig,
+ source, sourceTarget);
+ return rcl;
+ }
+
+ public static AbstractXMLObject findXMLObjectByName(String selector,
+ AbstractXMLObject root) {
+ if (selector == null)
+ return null;
+ if (selector.equals(root.getName())) {
+ return root;
+ }
+ if (root instanceof TagObject) {
+ List properties = ((TagObject) root).getProperties();
+ for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
+ TagPropertyObject pro = (TagPropertyObject) iterator.next();
+ if (selector.equals(pro.getName()))
+ return pro;
+ }
+ List<AbstractXMLObject> tags = ((TagObject) root).getChildren();
+ for (Iterator iterator = tags.iterator(); iterator.hasNext();) {
+ AbstractXMLObject tagChild = (AbstractXMLObject) iterator
+ .next();
+ AbstractXMLObject result = findXMLObjectByName(selector,
+ tagChild);
+ if (result != null)
+ return result;
+ }
+ }
+ return null;
+
+ }
+
+ protected void createMappingResourceConfigList(
+ MappingResourceConfigList configList, SmooksResourceListType list,
+ ResourceConfigType config, AbstractXMLObject sourceRoot,
+ JavaBeanModel targetJavaBean) {
+ String selector = config.getSelector();
+ String beanID = SmooksModelUtils.getParmaText(
+ SmooksModelConstants.BEAN_ID, config);
+ String beanClass = SmooksModelUtils.getParmaText(
+ SmooksModelConstants.BEAN_CLASS, config);
+
+ MappingModel mapping = new MappingModel(sourceRoot, targetJavaBean);
+ configList.getMappingModelList().add(mapping);
+ configList.addResourceConfig(config);
+ this.setSelectorIsUsed(config.getSelector());
+
+ List<ParamType> paramList = config.getParam();
+ ParamType bindingParam = null;
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType paramType = (ParamType) iterator.next();
+ String name = paramType.getName();
+ if (SmooksModelConstants.BINDINGS.equals(name)) {
+ bindingParam = paramType;
+ break;
+ }
+ }
+
+ if (bindingParam != null) {
+ List bindings = (List) bindingParam.getMixed().get(
+ SmooksModelUtils.ELEMENT_BINDING, true);
+ if (bindings != null) {
+ for (Iterator iterator = bindings.iterator(); iterator
+ .hasNext();) {
+ AnyType binding = (AnyType) iterator.next();
+ String property = SmooksModelUtils
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_PROPERTY);
+ String selectorStr = SmooksModelUtils
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_SELECTOR);
+ JavaBeanModel childBean = JavaBeanAnalyzer
+ .findTheChildJavaBeanModel(property, targetJavaBean);
+ processXMLSelector(configList, config, sourceRoot,
+ childBean, list, selectorStr);
+ }
+ }
+ }
+ }
+
+ protected void processXMLSelector(MappingResourceConfigList configList,
+ ResourceConfigType resourceConfig, AbstractXMLObject root,
+ JavaBeanModel targetBean, SmooksResourceListType listType,
+ String selector) {
+ if (isReferenceSelector(selector)) {
+ ResourceConfigType resourceConfig1 = this
+ .findResourceConfigTypeWithSelector(selector, listType);
+ String newSelector = resourceConfig1.getSelector();
+ if (newSelector == null)
+ return;
+ AbstractXMLObject newRoot = findXMLObjectByName(newSelector, root);
+ createMappingResourceConfigList(configList, listType,
+ resourceConfig1, newRoot, targetBean);
+ } else {
+ AbstractXMLObject source = findXMLObjectWithSelectorString(
+ selector, root);
+ if (source != null) {
+ MappingModel mapping = new MappingModel(source, targetBean);
+ configList.getMappingModelList().add(mapping);
+ configList.addResourceConfig(resourceConfig);
+ this.setSelectorIsUsed(selector);
+ }
+ }
+ }
+
+ public static AbstractXMLObject findXMLObjectWithSelectorString(
+ String selector, AbstractXMLObject parent) {
+ if (selector == null)
+ return null;
+ selector = selector.trim();
+ String[] names = selector.split(" ");
+ if (names == null)
+ return null;
+ AbstractXMLObject current = parent;
+ for (int i = 0; i < names.length; i++) {
+ 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
+ .next();
+ if (name.equals(property.getName())) {
+ current = property;
+ }
+ }
+ } else {
+ List list = parent.getChildren();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ AbstractXMLObject child = (AbstractXMLObject) iterator
+ .next();
+ if (name.equals(child.getName())) {
+ current = child;
+ break;
+ }
+ }
+ }
+ }
+ if (current == parent)
+ return null;
+ return current;
+ }
+
+ public static boolean isXMLAttributeObject(String name) {
+ if (name != null && name.startsWith("@"))
+ return true;
+ return false;
+ }
+
+ private ResourceConfigType findFirstMappingResourceConfig(
+ SmooksResourceListType listType) {
+ List list = listType.getAbstractResourceConfig();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ ResourceConfigType resource = (ResourceConfigType) iterator.next();
+ ResourceType rt = resource.getResource();
+ if (rt == null)
+ continue;
+ String value = rt.getValue();
+ if (SmooksModelConstants.BEAN_POPULATOR.equals(value)) {
+ return resource;
+ }
+ }
+ return null;
+ }
+
+ public DesignTimeAnalyzeResult analyzeGraphModel(
+ SmooksConfigurationFileGenerateContext context) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.xml2java.analyzer;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.DocumentException;
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.smooks.analyzer.ISourceModelAnalyzer;
+import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.jboss.tools.smooks.graphical.Param;
+import org.jboss.tools.smooks.graphical.Params;
+import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
+import org.jboss.tools.smooks.xml.model.DocumentObject;
+import org.jboss.tools.smooks.xml.model.XMLObjectAnalyzer;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 23, 2008
+ */
+public class XMLSourceModelAnalyzer implements ISourceModelAnalyzer {
+
+ public static final String XML_FILE = "xmlFile";
+
+ public Object buildSourceInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException {
+ Params params = graphInfo.getParams();
+ String path = null;
+ if (params != null) {
+ List<Param> paramList = graphInfo.getParams().getParam();
+ for (Iterator<Param> iterator = paramList.iterator(); iterator
+ .hasNext();) {
+ Param param = (Param) iterator.next();
+ if (param.getName().equals(XML_FILE)) {
+ path = param.getValue();
+ break;
+ }
+ }
+ }
+ if (path == null) {
+ // TODO tell user the filepath can't find or not ?
+ return null;
+// throw new InvocationTargetException(new Exception(
+// "xml file path can't find in the graphInfo file"));
+ }
+ XMLObjectAnalyzer objectBuilder = new XMLObjectAnalyzer();
+ try {
+ FileInputStream stream = new FileInputStream(path);
+ DocumentObject document = objectBuilder.analyze(stream);
+ return document;
+ } catch (FileNotFoundException e) {
+ throw new InvocationTargetException(e);
+ } catch (DocumentException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml2xml;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.analyzer.AbstractAnalyzer;
+import org.jboss.tools.smooks.analyzer.DesignTimeAnalyzeResult;
+import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
+import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
+import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+
+/**
+ * @author dart
+ *
+ */
+public class XML2XMLAnalyzer extends AbstractAnalyzer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel(org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext)
+ */
+ public void analyzeMappingGraphModel(
+ SmooksConfigurationFileGenerateContext context)
+ throws SmooksAnalyzerException {
+ if (true) {
+ Shell shell = context.getShell();
+ MessageDialog.openWarning(shell, "Warning",
+ "The xml2xml can't be generate to config file currently.");
+ return;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingSmooksModel(org.jboss.tools.smooks.model.SmooksResourceListType,
+ * java.lang.Object, java.lang.Object)
+ */
+ public MappingResourceConfigList analyzeMappingSmooksModel(
+ SmooksResourceListType listType, Object sourceObject,
+ Object targetObject) {
+ return null;
+ }
+
+ public DesignTimeAnalyzeResult analyzeGraphModel(
+ SmooksConfigurationFileGenerateContext context) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelContentProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelContentProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelContentProvider.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.xsd.model;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.xsd.provider.XSDItemProviderAdapterFactory;
+
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 24, 2008
+ */
+public class XSDStructuredModelContentProvider extends AdapterFactoryContentProvider {
+ public XSDStructuredModelContentProvider() {
+ super(new XSDItemProviderAdapterFactory());
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelLabelProvider.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelLabelProvider.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelLabelProvider.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.xsd.model;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.xsd.provider.XSDItemProviderAdapterFactory;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 30, 2008
+ */
+public class XSDStructuredModelLabelProvider extends AdapterFactoryLabelProvider {
+
+ public XSDStructuredModelLabelProvider() {
+ super(new XSDItemProviderAdapterFactory());
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/model/XSDStructuredModelLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.xsd.ui;
+
+import java.util.Properties;
+
+import org.eclipse.jface.wizard.IWizardNode;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.xml.AbstractFileSelectionWizardPage;
+import org.jboss.tools.smooks.xml.AbstractStructuredDdataWizard;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 18, 2008
+ */
+public class XSDStructuredDataWizard extends AbstractStructuredDdataWizard {
+ IWizardNode wizard;
+ Properties properties = new Properties();
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.xml.AbstractStructuredDdataWizard#createAbstractFileSelectionWizardPage()
+ */
+ @Override
+ protected AbstractFileSelectionWizardPage createAbstractFileSelectionWizardPage() {
+ return new XSDStructuredDataWizardPage("XSD");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.ui.IStrucutredDataCreationWizard#getInputDataTypeID()
+ */
+ public String getInputDataTypeID() {
+ return SmooksUIActivator.TYPE_ID_XSD;
+ }
+ public Properties getProperties() {
+ return this.properties;
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizardPage.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizardPage.java 2008-10-20 10:10:26 UTC (rev 10974)
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xsd.ui;
+
+import java.util.Collections;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.util.XSDResourceFactoryImpl;
+import org.jboss.tools.smooks.xml.AbstractFileSelectionWizardPage;
+
+/**
+ * @author Dart Peng
+ * Date : 2008-8-16
+ */
+public class XSDStructuredDataWizardPage extends
+ AbstractFileSelectionWizardPage {
+
+// public XSDStructuredDataWizardPage(String pageName, String title,
+// ImageDescriptor titleImage) {
+// super(pageName, title, titleImage);
+// // TODO Auto-generated constructor stub
+// }
+
+ public XSDStructuredDataWizardPage(String pageName) {
+ super(pageName);
+ this.setTitle("XSD File Selection");
+ this.setMessage("Select a *.xsd file to loaded ");
+ }
+ protected Object loadedTheObject(String path) throws Exception {
+ Resource resource = new XSDResourceFactoryImpl().createResource(URI
+ .createFileURI(path));
+ resource.load(Collections.EMPTY_MAP);
+ XSDSchema schema = (XSDSchema) resource.getContents().get(0);
+ return schema;
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xsd/ui/XSDStructuredDataWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF 2008-10-20 10:08:30 UTC (rev 10973)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF 2008-10-20 10:10:26 UTC (rev 10974)
@@ -4,20 +4,17 @@
Bundle-SymbolicName: org.jboss.tools.smooks.test
Bundle-Version: 1.0.0
Bundle-Activator: org.jboss.tools.smooks.test.Activator
-Require-Bundle: org.eclipse.ui,
+Require-Bundle: org.junit,
+ org.eclipse.ui,
org.eclipse.core.runtime,
- org.jboss.tools.smooks.javabean,
- org.jboss.tools.smooks.model,
- org.jboss.tools.smooks.model.edit,
- org.jboss.tools.smooks.ui,
- org.jboss.tools.smooks.xml,
- org.junit,
org.eclipse.core.resources,
org.eclipse.xsd,
org.eclipse.xsd.edit,
org.eclipse.emf,
org.eclipse.emf.ecore.edit,
- org.eclipse.emf.edit.ui
+ org.eclipse.emf.edit.ui,
+ org.jboss.tools.smooks.ui,
+ org.jboss.tools.smooks.core
Eclipse-LazyStart: true
Bundle-ClassPath: lib/dom4j-1.6.1.jar,
.
16 years, 2 months
JBoss Tools SVN: r10971 - branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-10-20 06:06:06 -0400 (Mon, 20 Oct 2008)
New Revision: 10971
Modified:
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2345
http://jira.jboss.com/jira/browse/JBIDE-2344
Modified: branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java 2008-10-20 10:05:24 UTC (rev 10970)
+++ branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java 2008-10-20 10:06:06 UTC (rev 10971)
@@ -101,7 +101,7 @@
selectMethod = new Button(container, SWT.CHECK);
selectMethod.setText("Use Console Configuration");
selectMethod.setSelection(true);
- selectMethod.setEnabled(false);
+ //selectMethod.setEnabled(false);
selectMethod.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e) {
@@ -112,6 +112,9 @@
consoleConfigurationName.setEnabled(selectMethod.getSelection());
connectionProfileName.setEnabled(!selectMethod.getSelection());
schemaName.setEnabled(!selectMethod.getSelection());
+ if (!selectMethod.getSelection()){
+ setMessage("Hibernate dialect is not specified", WARNING);
+ }
dialogChanged();
}});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
16 years, 2 months
JBoss Tools SVN: r10970 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-10-20 06:05:24 -0400 (Mon, 20 Oct 2008)
New Revision: 10970
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2345
http://jira.jboss.com/jira/browse/JBIDE-2344
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java 2008-10-20 09:58:30 UTC (rev 10969)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java 2008-10-20 10:05:24 UTC (rev 10970)
@@ -101,7 +101,7 @@
selectMethod = new Button(container, SWT.CHECK);
selectMethod.setText("Use Console Configuration");
selectMethod.setSelection(true);
- selectMethod.setEnabled(false);
+ //selectMethod.setEnabled(false);
selectMethod.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e) {
@@ -112,6 +112,9 @@
consoleConfigurationName.setEnabled(selectMethod.getSelection());
connectionProfileName.setEnabled(!selectMethod.getSelection());
schemaName.setEnabled(!selectMethod.getSelection());
+ if (!selectMethod.getSelection()){
+ setMessage("Hibernate dialect is not specified", WARNING);
+ }
dialogChanged();
}});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
16 years, 2 months
JBoss Tools SVN: r10967 - branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-10-20 05:44:15 -0400 (Mon, 20 Oct 2008)
New Revision: 10967
Modified:
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1178
Reveng filter storage moved from launch configuration to xml file.
File stored in .settings dir of the project.
Modified: branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-10-20 09:44:10 UTC (rev 10966)
+++ branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-10-20 09:44:15 UTC (rev 10967)
@@ -266,7 +266,6 @@
final String reverseEngineeringStrategy = attributes.getRevengStrategy();
final boolean preferBasicCompositeids = attributes.isPreferBasicCompositeIds();
final IResource revengres = PathHelper.findMember( root, attributes.getRevengSettings());
- final String revengTables = attributes.getRevengTables();
if(reveng) {
Configuration configuration = null;
@@ -291,12 +290,7 @@
OverrideRepository repository = null;
- if (revengTables != null){
- repository = new OverrideRepository();
- repository.addInputStream(new ByteArrayInputStream(revengTables.getBytes()));
- } else if(revengres!=null) {
- /*Configuration configuration = cc.buildWith(new Configuration(), false);*/
- /*Settings settings = cc.getSettings(configuration);*/
+ if(revengres!=null) {
File file = PathHelper.getLocation( revengres ).toFile();
repository = new OverrideRepository();
repository.addFile(file);
Modified: branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2008-10-20 09:44:10 UTC (rev 10966)
+++ branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2008-10-20 09:44:15 UTC (rev 10967)
@@ -74,7 +74,6 @@
private String templatePath;
private List exporterFactories;
// if set then build reveng strategy relying on the list of tables
- private String revengTables;
private boolean autoManyToManyDetection;
private boolean autoVersioning;
@@ -110,7 +109,6 @@
}
exporterFactories = readExporterFactories(configuration);
- revengTables = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVENG_TABLES, (String)null);
} catch (CoreException e) {
throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
}
@@ -347,19 +345,12 @@
return exporterFactories;
}
-public boolean detectManyToMany() {
- return autoManyToManyDetection;
-}
+ public boolean detectManyToMany() {
+ return autoManyToManyDetection;
+ }
public boolean detectOptimisticLock() {
return autoVersioning;
}
- public String getRevengTables() {
- return revengTables;
- }
-
-
-
-
}
16 years, 2 months
JBoss Tools SVN: r10966 - branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-10-20 05:44:10 -0400 (Mon, 20 Oct 2008)
New Revision: 10966
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1178
Reveng filter storage moved from launch configuration to xml file.
File stored in .settings dir of the project.
Modified: branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-10-20 09:40:54 UTC (rev 10965)
+++ branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-10-20 09:44:10 UTC (rev 10966)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -21,6 +22,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -317,7 +319,11 @@
wc.doSave();
if (params.containsKey(HibernateLaunchConstants.ATTR_REVENG_TABLES)){
- wc.setAttribute(HibernateLaunchConstants.ATTR_REVENG_TABLES, params.get(HibernateLaunchConstants.ATTR_REVENG_TABLES));
+ //create reveng.xml file
+ IPath revengPath = project.getLocation().append(".settings").append("gen-entities.hibernate.reveng.xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ File location = revengPath.toFile();
+ org.jboss.tools.common.util.FileUtil.writeFile(location, params.get(HibernateLaunchConstants.ATTR_REVENG_TABLES));
+ wc.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, revengPath.toString());
}
launchManager.addLaunch(wc.launch(ILaunchManager.RUN_MODE, monitor));
16 years, 2 months