Author: bfitzpat
Date: 2009-12-11 14:51:00 -0500 (Fri, 11 Dec 2009)
New Revision: 19226
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/SmooksTemplatingActivator.java
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin_ja.properties
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/CollectionMapping.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/Mapping.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/ModelBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/TemplateBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVFreeMarkerTemplateBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVModelBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/InvalidMappingException.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/TemplateBuilderException.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/UnmappedCollectionNodeException.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/util/FreeMarkerUtil.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDFreeMarkerTemplateBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDModelBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDToFreemarkerTemplateBuilder.java
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/
Modified:
trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml
trunk/smooks/plugins/org.jboss.tools.smooks.templating/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.templating/build.properties
trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.properties
trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project
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/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerCSVContentGenerator.java
Log:
JBIDE-5205: Create FreeMarker Template builder for generating XML messages (from XSD)
https://jira.jboss.org/jira/browse/JBIDE-5205
Modified: trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml
===================================================================
--- trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml 2009-12-11 17:18:15
UTC (rev 19225)
+++ trunk/smooks/features/org.jboss.tools.smooks.feature/feature.xml 2009-12-11 19:51:00
UTC (rev 19226)
@@ -43,4 +43,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.jboss.tools.smooks.templating"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.templating/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.templating/META-INF/MANIFEST.MF 2009-12-11
17:18:15 UTC (rev 19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.templating/META-INF/MANIFEST.MF 2009-12-11
19:51:00 UTC (rev 19226)
@@ -7,12 +7,14 @@
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
-Bundle-ClassPath: libs/xstream-1.2.2.jar
+Bundle-ClassPath: .,
+ libs/xstream-1.2.2.jar
Require-Bundle: org.jboss.tools.smooks.runtime,
org.eclipse.xsd,
org.eclipse.emf,
org.eclipse.core.runtime
-Export-Package: org.jboss.tools.smooks.templating.model,
+Export-Package: org.jboss.tools.smooks.templating,
+ org.jboss.tools.smooks.templating.model,
org.jboss.tools.smooks.templating.model.csv,
org.jboss.tools.smooks.templating.model.xml,
org.jboss.tools.smooks.templating.template,
@@ -20,3 +22,4 @@
org.jboss.tools.smooks.templating.template.exception,
org.jboss.tools.smooks.templating.template.util,
org.jboss.tools.smooks.templating.template.xml
+Bundle-Activator: org.jboss.tools.smooks.templating.SmooksTemplatingActivator
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.templating/build.properties
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.templating/build.properties 2009-12-11
17:18:15 UTC (rev 19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.templating/build.properties 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,7 +1,9 @@
output.. = bin/
-bin.includes = plugin.xml,\
- META-INF/,\
+bin.includes = META-INF/,\
+ .,\
about.html,\
- jboss_about.png,\
- plugin.properties,\
- libs/xstream-1.2.2.jar
+ libs/xstream-1.2.2.jar,\
+ plugin.properties
+jars.compile.order = .
+source.. = src/
+source.. = src/
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.properties
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.properties 2009-12-11
17:18:15 UTC (rev 19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.properties 2009-12-11
19:51:00 UTC (rev 19226)
@@ -5,93 +5,4 @@
# $Id$
providerName = JBoss by Red Hat
-pluginName = Smooks Tools UI Plug-in
-
-_UI_EdiEditor_menu = &Edi Editor
-_UI_CommonEditor_menu = &Common Editor
-
-_UI_CreateChild_menu_item = &New Child
-_UI_CreateSibling_menu_item = N&ew Sibling
-
-_UI_ShowPropertiesView_menu_item = Show &Properties View
-_UI_RefreshViewer_menu_item = &Refresh
-
-_UI_SelectionPage_label = Selection
-_UI_ParentPage_label = Parent
-_UI_ListPage_label = List
-_UI_TreePage_label = Tree
-_UI_TablePage_label = Table
-_UI_TreeWithColumnsPage_label = Tree with Columns
-_UI_ObjectColumn_label = Object
-_UI_SelfColumn_label = Self
-
-_UI_XMLTypeDocumentRoot_cDATA_feature = "CDATA"
-
-_UI_NoObjectSelected = Selected Nothing
-_UI_SingleObjectSelected = Selected Object: {0}
-_UI_MultiObjectSelected = Selected {0} Objects
-
-_UI_OpenEditorError_label = Open Editor
-
-_UI_Wizard_category = Example EMF Model Creation Wizards
-
-_UI_CreateModelError_message = Problems encountered in file "{0}"
-
-_UI_EdiModelWizard_label = Edi Model
-_UI_EdiModelWizard_description = Create a new Edi model
-
-_UI_EdiEditor_label = Edi Model Editor
-
-_UI_EdiEditorFilenameDefaultBase = My
-_UI_EdiEditorFilenameExtensions = edi
-
-_UI_CommonModelWizard_label = Common Model
-_UI_CommonModelWizard_description = Create a new Common model
-
-_UI_CommonEditor_label = Common Model Editor
-
-_UI_CommonEditorFilenameDefaultBase = My
-_UI_CommonEditorFilenameExtensions = common
-
-_UI_Wizard_label = New
-
-_WARN_FilenameExtension = The file name must end in ''.{0}''
-_WARN_FilenameExtensions = The file name must have one of the following extensions: {0}
-
-_UI_ModelObject = &Model Object
-_UI_XMLEncoding = &XML Encoding
-_UI_XMLEncodingChoices = UTF-8 ASCII UTF-16 UTF-16BE UTF-16LE ISO-8859-1
-_UI_Wizard_initial_object_description = Select a model object to create
-
-_UI_FileConflict_label = File Conflict
-_WARN_FileConflict = There are unsaved changes that conflict with changes made outside
the editor. Do you wish to discard this editor's changes?
-
-# For FreeMarker
-_UI_FreemarkerEditor_menu = &Freemarker Editor
-_UI_SmooksEditor_menu = &Smooks Editor
-_UI_FreemarkerModelWizard_label = Freemarker Model
-_UI_FreemarkerModelWizard_description = Create a new Freemarker model
-_UI_FreemarkerEditor_label = Freemarker Model Editor
-_UI_FreemarkerEditorFilenameDefaultBase = My
-_UI_FreemarkerEditorFilenameExtensions = freemarker
-
-_UI_SmooksModelWizard_label = Smooks Model
-_UI_SmooksModelWizard_description = Create a new Smooks model
-_UI_SmooksEditor_label = Smooks Model Editor
-_UI_SmooksEditorFilenameDefaultBase = My
-_UI_SmooksEditorFilenameExtensions = smooks
-
-# For Javabean
-_UI_JavabeanEditor_menu = &Javabean Editor
-_UI_JavabeanModelWizard_label = Javabean Model
-_UI_JavabeanModelWizard_description = Create a new Javabean model
-_UI_JavabeanEditor_label = Javabean Model Editor
-_UI_JavabeanEditorFilenameDefaultBase = My
-_UI_JavabeanEditorFilenameExtensions = javabean
-_UI_XslEditor_menu = &Xsl Editor
-_UI_XslModelWizard_label = Xsl Model
-_UI_XslModelWizard_description = Create a new Xsl model
-_UI_XslEditor_label = Xsl Model Editor
-_UI_XslEditorFilenameDefaultBase = My
-_UI_XslEditorFilenameExtensions = xsl
-launch.shortcut.text=Smooks Run Configuration
+pluginName = Smooks Templating Plug-in
Deleted: trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.xml 2009-12-11 17:18:15
UTC (rev 19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin.xml 2009-12-11 19:51:00
UTC (rev 19226)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
-
-
-
-</plugin>
Deleted: trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin_ja.properties
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin_ja.properties 2009-12-11
17:18:15 UTC (rev 19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.templating/plugin_ja.properties 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,2 +0,0 @@
-pluginName=Smooks Tools
-providerName=JBoss by Red Hat
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/SmooksTemplatingActivator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/SmooksTemplatingActivator.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/SmooksTemplatingActivator.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -0,0 +1,10 @@
+package org.jboss.tools.smooks.templating;
+
+import org.eclipse.core.runtime.Plugin;
+
+public class SmooksTemplatingActivator extends Plugin {
+
+ public SmooksTemplatingActivator() {
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/SmooksTemplatingActivator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project 2009-12-11 17:18:15 UTC (rev
19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project 2009-12-11 19:51:00 UTC (rev
19226)
@@ -29,12 +29,12 @@
<link>
<name>smooks-core</name>
<type>2</type>
- <location>D:/Users/tfennelly/milyn/trunk/smooks-core/src/main/java</location>
+ <location>/Users/tfennelly/packs/eclipse/Eclipse.app/Contents/MacOS/D::/Users/tfennelly/milyn/trunk/smooks-core/src/main/java</location>
</link>
<link>
<name>smooks-csv</name>
<type>2</type>
- <location>D:/Users/tfennelly/milyn/trunk/smooks-cartridges/csv/src/main/java</location>
+ <location>/Users/tfennelly/packs/eclipse/Eclipse.app/Contents/MacOS/D::/Users/tfennelly/milyn/trunk/smooks-cartridges/csv/src/main/java</location>
</link>
</linkedResources>
</projectDescription>
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 2009-12-11
17:18:15 UTC (rev 19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-12-11
19:51:00 UTC (rev 19226)
@@ -25,6 +25,7 @@
org.apache.xerces,
javax.wsdl,
org.jboss.tools.smooks.runtime,
+ org.jboss.tools.smooks.templating,
org.eclipse.gef,
org.eclipse.jdt.launching,
org.eclipse.core.filesystem,
@@ -44,11 +45,7 @@
Bundle-ClassPath: libs/dom4j-1.6.1.jar,
.,
libs/xstream-1.2.2.jar
-Export-Package: org.jboss.template,
- org.jboss.template.csv,
- org.jboss.template.exception,
- org.jboss.template.xsd,
- org.jboss.tools.smooks.configuration,
+Export-Package: org.jboss.tools.smooks.configuration,
org.jboss.tools.smooks.configuration.editors,
org.jboss.tools.smooks.configuration.editors.csv,
org.jboss.tools.smooks.configuration.editors.edi,
@@ -57,5 +54,5 @@
org.jboss.tools.smooks.configuration.editors.xml,
org.jboss.tools.smooks.edimap.editor,
org.jboss.tools.smooks.editor,
- org.jboss.tools.smooks.launch,
- org.jboss.tools.smooks.graphical.editors
+ org.jboss.tools.smooks.graphical.editors,
+ org.jboss.tools.smooks.launch
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/build.properties
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/build.properties 2009-12-11 17:18:15
UTC (rev 19225)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/build.properties 2009-12-11 19:51:00
UTC (rev 19226)
@@ -4,12 +4,10 @@
META-INF/,\
.,\
icons/,\
- libs/dom4j-1.6.1.jar,\
about.html,\
about.ini,\
about.mappings,\
about.properties,\
jboss_about.png,\
plugin.properties,\
- schema/,\
- libs/xstream-1.2.2.jar
+ schema/
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/CollectionMapping.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/CollectionMapping.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/CollectionMapping.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template;
-
-import org.eclipse.core.runtime.Assert;
-import org.w3c.dom.Node;
-
-/**
- * Collection {@link Mapping}.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class CollectionMapping extends Mapping {
-
- private String collectionItemName;
-
- /**
- * Public constructor.
- *
- * @param srcPath Source path.
- * @param mappingNode The mapping node.
- */
- public CollectionMapping(String srcPath, Node mappingNode, String collectionItemName)
{
- super(srcPath, mappingNode);
- Assert.isNotNull(collectionItemName, "collectionItemName");
//$NON-NLS-1$
- this.collectionItemName = collectionItemName;
- }
-
- public String getCollectionItemName() {
- return collectionItemName;
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/Mapping.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/Mapping.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/Mapping.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.w3c.dom.Node;
-
-/**
- * Model template mapping.
- * <p/>
- * Represents a successful mapping. It also tells if the mapping requires
- * other model nodes to be hidden, so as to restrict mappings to these nodes.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class Mapping {
-
- private String srcPath;
- private Node mappingNode;
- private List<Node> hideNodes;
- private List<Node> showNodes;
-
- /**
- * Public constructor.
- * @param srcPath Source path.
- * @param mappingNode The mapping node.
- */
- public Mapping(String srcPath, Node mappingNode) {
- Assert.isNotNull(srcPath, "srcPath"); //$NON-NLS-1$
- Assert.isNotNull(mappingNode, "mappingNode"); //$NON-NLS-1$
- this.srcPath = srcPath;
- this.mappingNode = mappingNode;
- }
-
- public String getSrcPath() {
- return srcPath;
- }
-
- public Node getMappingNode() {
- return mappingNode;
- }
-
- public List<Node> getHideNodes() {
- return hideNodes;
- }
-
- public List<Node> getShowNodes() {
- return showNodes;
- }
-
- public void addHideNode(Node node) {
- Assert.isNotNull(node, "node"); //$NON-NLS-1$
-
- if(hideNodes == null) {
- hideNodes = new ArrayList<Node>();
- }
-
- hideNodes.add(node);
- }
-
- public void addShowNode(Node node) {
- Assert.isNotNull(node, "node"); //$NON-NLS-1$
-
- if(showNodes == null) {
- showNodes = new ArrayList<Node>();
- }
-
- showNodes.add(node);
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/ModelBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/ModelBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/ModelBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,133 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.jboss.template.exception.TemplateBuilderException;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * Abstract templating model builder.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public abstract class ModelBuilder {
-
- public static final String NAMESPACE =
"http://www.jboss.org/xsd/tools/smooks"; // TODO: Make same as JBT eclipse
extension namespace ?? //$NON-NLS-1$
- public static final String REQUIRED = "#required"; //$NON-NLS-1$
- public static final String OPTIONAL = "#optional"; //$NON-NLS-1$
-
- private static final String HIDDEN_ELEMENT = "hidden"; //$NON-NLS-1$
-
- /**
- * Build the templating model.
- * @return The templating model.
- * @throws TemplateBuilderException Error building model.
- */
- public abstract Document buildModel() throws TemplateBuilderException;
-
- /**
- * Mark a fragment as being hidden.
- * <p/>
- * When hidden, it is illegal to attempt a mapping onto a fragment.
- *
- * @param fragment The fragment to be marked as hidden.
- */
- public static void hideFragment(Element fragment) {
- fragment.setAttributeNS(NAMESPACE, HIDDEN_ELEMENT, "true");
//$NON-NLS-1$
- }
-
- /**
- * Unmark a fragment as being hidden.
- * <p/>
- * When hidden, it is illegal to attempt a mapping onto a fragment.
- *
- * @param fragment The fragment to be unmarked as hidden.
- */
- public static void unhideFragment(Element fragment) {
- fragment.removeAttributeNS(NAMESPACE, HIDDEN_ELEMENT);
- }
-
- /**
- * Is the specified node marked as being hidden.
- * <p/>
- * When hidden, it is illegal to attempt a mapping onto a fragment.
- *
- * @return True if the node is hidden, otherwise false.
- */
- public static boolean isHidden(Node node) {
- if(node != null) {
- switch(node.getNodeType()) {
- case Node.ATTRIBUTE_NODE :
- return isHidden(node.getParentNode());
- case Node.ELEMENT_NODE :
- if(((Element)node).getAttributeNS(NAMESPACE,
HIDDEN_ELEMENT).equals("true")) { //$NON-NLS-1$
- return true;
- }
- return isHidden(node.getParentNode());
- }
- }
-
- return false;
- }
-
- protected Document createModelInstance() throws TemplateBuilderException {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
-
- try {
- builder = builderFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw new TemplateBuilderException("Error constructing DOM
DocumentBuilder.", e); //$NON-NLS-1$
- }
-
- return builder.newDocument();
- }
-
- protected void setMinMax(Element element, int minOccurs, int maxOccurs) {
- element.setAttributeNS(NAMESPACE, "smk:minOccurs",
Integer.toString(minOccurs)); //$NON-NLS-1$
- element.setAttributeNS(NAMESPACE, "smk:maxOccurs",
Integer.toString(maxOccurs)); //$NON-NLS-1$
- }
-
- public static int getMinOccurs(Element element) {
- String minOccurs = element.getAttributeNS(NAMESPACE, "minOccurs");
//$NON-NLS-1$
-
- if(minOccurs.equals("")) { //$NON-NLS-1$
- return 1;
- }
-
- return Integer.parseInt(minOccurs);
- }
-
- public static int getMaxOccurs(Element element) {
- String maxOccurs = element.getAttributeNS(NAMESPACE, "maxOccurs");
//$NON-NLS-1$
-
- if(maxOccurs.equals("")) { //$NON-NLS-1$
- return 1;
- }
-
- return Integer.parseInt(maxOccurs);
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/TemplateBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/TemplateBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/TemplateBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,171 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.jboss.template.exception.InvalidMappingException;
-import org.jboss.template.exception.TemplateBuilderException;
-import org.jboss.template.exception.UnmappedCollectionNodeException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public abstract class TemplateBuilder {
-
- private Document model;
- private List<Mapping> mappings = new ArrayList<Mapping>();
-
- /**
- * Public constructor.
- * @param model The model on which the template will be constructed.
- */
- public TemplateBuilder(Document model) {
- Assert.isNotNull(model, "model"); //$NON-NLS-1$
- this.model = model;
- }
-
- /**
- * Build the template for the specified model, based on the supplied mappings.
- * @return The template.
- * @throws org.jboss.template.exception.TemplateBuilderException Exception building
template.
- */
- public abstract String buildTemplate() throws TemplateBuilderException;
-
- /**
- * Get the model associated with the template.
- * @return The model.
- */
- public Document getModel() {
- return model;
- }
-
- /**
- * Add a source to model value mapping.
- * @param srcPath Source path. Depends on the source type e.g. will be a java
- * object graph path for a bean property and will be an xml path for an XML source.
- * @param modelPath The mapping path in the target model.
- * @return The mapping instance.
- * @throws InvalidMappingException Invalid mapping.
- */
- public Mapping addValueMapping(String srcPath, Node modelPath) throws
InvalidMappingException {
- asserValidMappingNode(modelPath);
- Mapping mapping = new Mapping(srcPath, modelPath);
- mappings.add(mapping);
- return mapping;
- }
-
- /**
- * Add a source to model collection mapping.
- * @param srcCollectionPath Source path.
- * @param modelCollectionPath The mapping path in the target model.
- * @param collectionItemName The name associated with the individual collection
items.
- * @return The mapping instance.
- * @throws InvalidMappingException Invalid mapping.
- */
- public Mapping addCollectionMapping(String srcCollectionPath, Element
modelCollectionPath, String collectionItemName) throws InvalidMappingException {
- asserValidMappingNode(modelCollectionPath);
- Mapping mapping = new CollectionMapping(srcCollectionPath, modelCollectionPath,
collectionItemName);
- mappings.add(mapping);
- return mapping;
- }
-
- /**
- * Remove the specified mapping
- * @param mapping The mapping instance to be removed.
- * @return True if the mapping was successfully removed, otherwise false.
- */
- public boolean removeMapping(Mapping mapping) {
- return mappings.remove(mapping);
- }
-
- /**
- * Get the full list of mappings.
- * @return The full list of mappings.
- */
- public List<Mapping> getMappings() {
- return mappings;
- }
-
- private void asserValidMappingNode(Node mappingNode) throws InvalidMappingException {
- if(mappingNode.getNodeType() != Node.ATTRIBUTE_NODE &&
mappingNode.getNodeType() != Node.ELEMENT_NODE) {
- throw new InvalidMappingException("Unsupported XML target node mapping.
Support XML elements and attributes only."); //$NON-NLS-1$
- }
- if(ModelBuilder.NAMESPACE.equals(mappingNode.getNamespaceURI())) {
- throw new InvalidMappingException("Unsupported XML target node mapping.
Cannot map to a reserved model node from the '" + ModelBuilder.NAMESPACE +
"' namespace."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if(ModelBuilder.isHidden(mappingNode)) {
- throw new InvalidMappingException("Illegal XML target node mapping for
node '" + mappingNode + "'. This node (or one of it's ancestors) is
hidden."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Make sure any parent collection nodes are mapped...
- Element collectionElement = getParentCollectionElement(mappingNode);
- if(collectionElement != null) {
- CollectionMapping parentCollectionMapping =
getCollectionMapping(collectionElement);
- if(parentCollectionMapping == null) {
- throw new UnmappedCollectionNodeException(collectionElement);
- }
- }
- }
-
- private Element getParentCollectionElement(Node modelPath) {
- Node parent = modelPath.getParentNode();
-
- while(parent != null) {
- if(parent.getNodeType() != Node.ELEMENT_NODE) {
- return null;
- }
-
- int maxOccurs = ModelBuilder.getMaxOccurs((Element) parent);
- if(maxOccurs > 1 || maxOccurs == -1) {
- return (Element) parent;
- }
-
- parent = parent.getParentNode();
- }
-
- return null;
- }
-
- protected CollectionMapping getCollectionMapping(Element collectionElement) {
- Mapping mapping = getMapping(collectionElement);
-
- if(mapping instanceof CollectionMapping) {
- return (CollectionMapping) mapping;
- }
-
- return null;
- }
-
- protected Mapping getMapping(Node node) {
- for(Mapping mapping : mappings) {
- if(mapping.getMappingNode() == node) {
- return mapping;
- }
- }
-
- return null;
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVFreeMarkerTemplateBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVFreeMarkerTemplateBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVFreeMarkerTemplateBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,175 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.csv;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Enumeration;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-import org.jboss.template.*;
-import org.jboss.template.exception.TemplateBuilderException;
-import org.jboss.template.exception.UnmappedCollectionNodeException;
-import org.jboss.template.util.FreeMarkerUtil;
-
-import au.com.bytecode.opencsv.CSVReader;
-
-import freemarker.core.TemplateElement;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-
-/**
- * Freemarker Template Builder for a CSV messages.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class CSVFreeMarkerTemplateBuilder extends TemplateBuilder {
-
- private char separatorChar;
- private char quoteChar;
-
- /**
- * Construct a new FreeMarker Template Builder with no mappings.
- * @param model The model.
- * @param separatorChar The CSV field separator character.
- * @param quoteChar The CSV field quote character.
- */
- public CSVFreeMarkerTemplateBuilder(Document model, char separatorChar, char
quoteChar) {
- super(model);
- this.separatorChar = separatorChar;
- this.quoteChar = quoteChar;
- }
-
- /**
- * Construct a new FreeMarker Template Builder, extracting the mappings from the
- * supplied FreeMarker template String.
- * @param model The model.
- * @param separatorChar The CSV field separator character.
- * @param quoteChar The CSV field quote character.
- * @param ftlTemplate The FreeMarker Template from which the mappings are to be
extracted.
- * @throws TemplateBuilderException Error parsing the supplied FreeMarker template.
- */
- public CSVFreeMarkerTemplateBuilder(Document model, char separatorChar, char
quoteChar, String ftlTemplate) throws TemplateBuilderException {
- this(model, separatorChar, quoteChar);
- addMappings(ftlTemplate);
- }
-
- private void addMappings(String ftlTemplate) throws TemplateBuilderException {
- Template template;
-
- try {
- template = new Template("csvTemplate", new StringReader(ftlTemplate), new
Configuration()); //$NON-NLS-1$
- } catch (IOException e) {
- throw new TemplateBuilderException ("Failed to parse the Supplied FreeMarker
template.", e); //$NON-NLS-1$
- }
-
- TemplateElement listElement = template.getRootTreeNode();
- if(!listElement.getNodeName().equals("IteratorBlock") ||
!listElement.getDescription().startsWith("list")) { //$NON-NLS-1$ //$NON-NLS-2$
- throw new TemplateBuilderException ("Unable to recognize template as being a CSV
template. Expecting first template token to be a 'list' IteratorBlock
node."); //$NON-NLS-1$
- }
-
- // Add the mapping for the list itself...
- addCSVListMapping(listElement.getDescription());
-
- // Add the mappings for the individual fields...
- addCSVFieldMappings(listElement);
- }
-
- private void addCSVListMapping(String description) throws TemplateBuilderException {
- String[] tokens = description.split(" +?"); //$NON-NLS-1$
- Element csvRecordElement = getModel().getDocumentElement();
-
- // 2nd and 4th tokens contain the info we're looking for e.g. "list
message.people as person"
- addCollectionMapping(tokens[1], csvRecordElement, tokens[3]);
- }
-
- private void addCSVFieldMappings(TemplateElement listElement) throws
TemplateBuilderException {
- StringBuilder parseBuffer = new StringBuilder();
- Enumeration children = listElement.children();
-
- while(children != null && children.hasMoreElements()) {
- TemplateElement child = (TemplateElement) children.nextElement();
- parseBuffer.append(child.getCanonicalForm());
- }
-
- Element csvRecordElement = getModel().getDocumentElement();
- CSVReader csvReader = new CSVReader(new StringReader(parseBuffer.toString()),
separatorChar, quoteChar);
- try {
- String[] fields = csvReader.readNext();
- int fieldIndex = 0;
- NodeList csvFieldModelNodes = csvRecordElement.getChildNodes();
-
- for(int i = 0; i < csvFieldModelNodes.getLength(); i++) {
- Node node = csvFieldModelNodes.item(i);
- if(node.getNodeType() == Node.ELEMENT_NODE) {
- if(fieldIndex >= fields.length) {
- throw new TemplateBuilderException("CSV Template fieldset size does not match
that of the specified message model. Check the supplied fieldset. Check the specified
'separator' and 'quote' characters match those used in the
template."); //$NON-NLS-1$
- }
-
- if(FreeMarkerUtil.isDollarVariable(fields[fieldIndex])) {
- addValueMapping(FreeMarkerUtil.extractJavaPath(fields[fieldIndex]), node);
- }
- fieldIndex++;
- }
- }
- } catch (IOException e) {
- throw new TemplateBuilderException("Failed to parse CSV fields in CSV
template.", e); //$NON-NLS-1$
- }
- }
-
- public String buildTemplate() throws TemplateBuilderException {
- Element recordElement = getModel().getDocumentElement();
- CollectionMapping collectionMapping = getCollectionMapping(recordElement);
-
- if(collectionMapping == null) {
- throw new UnmappedCollectionNodeException(recordElement);
- } else {
- StringBuilder template = new StringBuilder();
- NodeList nodeList = recordElement.getChildNodes();
- int fieldIndex = 0;
-
- template.append("<#list " + collectionMapping.getSrcPath() +
" as " + collectionMapping.getCollectionItemName() + ">\n");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- for(int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if(node.getNodeType() == Node.ELEMENT_NODE) {
- Mapping fieldMapping = getMapping(node);
-
- if(fieldIndex > 0) {
- template.append(separatorChar);
- }
-
- if(fieldMapping != null) {
- template.append(quoteChar);
- template.append("${" + fieldMapping.getSrcPath() +
"}"); //$NON-NLS-1$ //$NON-NLS-2$
- template.append(quoteChar);
- }
-
- fieldIndex++;
- }
- }
- template.append("\n</#list>"); //$NON-NLS-1$
-
- return template.toString();
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVModelBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVModelBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVModelBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.csv;
-
-import org.eclipse.core.runtime.Assert;
-import org.jboss.template.ModelBuilder;
-import org.jboss.template.exception.TemplateBuilderException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * CSV Model Builder.
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class CSVModelBuilder extends ModelBuilder {
-
- public static final String CSV_RECORD_ELEMENT = "csv-record";
//$NON-NLS-1$
- private String[] csvFields;
-
- public CSVModelBuilder(String... csvFields) {
- Assert.isNotNull(csvFields, "csvFields"); //$NON-NLS-1$
- this.csvFields = csvFields;
- }
-
- public Document buildModel() throws TemplateBuilderException {
- Document model = createModelInstance();
- Element record = model.createElement(CSV_RECORD_ELEMENT);
-
- model.appendChild(record);
- setMinMax(record, 0, -1);
- for(String field : csvFields) {
- record.appendChild(model.createElement(field));
- }
-
- return model;
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.csv;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-import org.jboss.template.*;
-import org.jboss.template.exception.TemplateBuilderException;
-import org.jboss.template.exception.UnmappedCollectionNodeException;
-
-/**
- * Freemarker Template Buidler for a CSV messages.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class CSVToFreemarkerTemplateBuilder extends TemplateBuilder {
-
- private char separatorChar;
- private char quoteChar;
-
- public CSVToFreemarkerTemplateBuilder(Document model, char separatorChar, char
quoteChar) {
- super(model);
- this.separatorChar = separatorChar;
- this.quoteChar = quoteChar;
- }
-
- public String buildTemplate() throws TemplateBuilderException {
- Element recordElement = getModel().getDocumentElement();
- CollectionMapping collectionMapping = getCollectionMapping(recordElement);
-
- if(collectionMapping == null) {
- throw new UnmappedCollectionNodeException(recordElement);
- } else {
- StringBuilder template = new StringBuilder();
- NodeList nodeList = recordElement.getChildNodes();
- int fieldIndex = 0;
-
- template.append("<#list " + collectionMapping.getSrcPath() +
" as " + collectionMapping.getCollectionItemName() + ">\n");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- for(int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if(node.getNodeType() == Node.ELEMENT_NODE) {
- Mapping fieldMapping = getMapping(node);
-
- if(fieldIndex > 0) {
- template.append(separatorChar);
- }
-
- if(fieldMapping != null) {
- template.append(quoteChar);
- template.append("${" + fieldMapping.getSrcPath() +
"}"); //$NON-NLS-1$ //$NON-NLS-2$
- template.append(quoteChar);
- }
-
- fieldIndex++;
- }
- }
- template.append("\n</#list>"); //$NON-NLS-1$
-
- return template.toString();
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/InvalidMappingException.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/InvalidMappingException.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/InvalidMappingException.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.exception;
-
-/**
- * Invalid mapping exception.
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class InvalidMappingException extends TemplateBuilderException {
-
- public InvalidMappingException(String message) {
- super(message);
- }
-
- public InvalidMappingException(String message, Throwable cause) {
- super(message, cause);
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/TemplateBuilderException.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/TemplateBuilderException.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/TemplateBuilderException.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.exception;
-
-import org.eclipse.xsd.XSDDiagnostic;
-
-import javax.xml.parsers.ParserConfigurationException;
-import java.util.List;
-
-/**
- * Template Builder Exception.
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class TemplateBuilderException extends Exception {
-
- public TemplateBuilderException(String message) {
- super(message);
- }
-
- public TemplateBuilderException(String message, Throwable cause) {
- super(message, cause);
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/UnmappedCollectionNodeException.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/UnmappedCollectionNodeException.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/exception/UnmappedCollectionNodeException.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.exception;
-
-import org.w3c.dom.Element;
-import org.milyn.xml.DomUtils;
-
-/**
- * Unmapped collection node exception.
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class UnmappedCollectionNodeException extends InvalidMappingException {
-
- private Element unmappedCollectionNode;
-
- public UnmappedCollectionNodeException(Element unmappedCollectionNode) {
- super("Unmapped collection node '" +
DomUtils.getName(unmappedCollectionNode) + "'."); //$NON-NLS-1$
//$NON-NLS-2$
- this.unmappedCollectionNode = unmappedCollectionNode;
- }
-
- public Element getUnmappedCollectionNode() {
- return unmappedCollectionNode;
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/util/FreeMarkerUtil.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/util/FreeMarkerUtil.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/util/FreeMarkerUtil.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.util;
-
-import org.jboss.template.exception.TemplateBuilderException;
-
-/**
- * FreeMarker utility methods.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class FreeMarkerUtil {
-
- public static String extractJavaPath(String dollarVariable) throws
TemplateBuilderException {
- dollarVariable = dollarVariable.trim();
-
- if(isDollarVariable(dollarVariable)) {
- return dollarVariable.substring(2, dollarVariable.length() - 1);
- } else {
- throw new TemplateBuilderException(""); //$NON-NLS-1$
- }
- }
-
- public static boolean isDollarVariable(String variable) {
- return (variable.startsWith("${") &&
variable.endsWith("}")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDFreeMarkerTemplateBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDFreeMarkerTemplateBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDFreeMarkerTemplateBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.xsd;
-
-import org.w3c.dom.Document;
-import org.milyn.xml.XmlUtil;
-import org.jboss.template.*;
-import org.jboss.template.exception.TemplateBuilderException;
-
-/**
- * Freemarker Template Buidler for a XSD messages.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class XSDFreeMarkerTemplateBuilder extends TemplateBuilder {
-
- public XSDFreeMarkerTemplateBuilder(Document model) {
- super(model);
- }
-
- public String buildTemplate() throws TemplateBuilderException {
- // TODO...
- return XmlUtil.serialize(getModel(), true);
- }
-}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDModelBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDModelBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDModelBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,280 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.xsd;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.eclipse.xsd.util.XSDResourceImpl;
-import org.eclipse.xsd.*;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Element;
-import org.jboss.template.exception.TemplateBuilderException;
-import org.jboss.template.ModelBuilder;
-
-import java.util.*;
-import java.io.IOException;
-import java.io.File;
-
-/**
- * Model Buidler for an XSD messages.
- * <p/>
- * Uses the Eclipse Schema Infoset Model API.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class XSDModelBuilder extends ModelBuilder {
-
- private Map<String, XSDElementDeclaration> elements = new
LinkedHashMap<String, XSDElementDeclaration>();
- private Map<String, XSDTypeDefinition> types = new LinkedHashMap<String,
XSDTypeDefinition>();
- private Set<String> loadedSchemas = new HashSet<String>();
- private Stack<XSDTypeDefinition> elementExpandStack = new
Stack<XSDTypeDefinition>();
- private String rootElementName;
-
- public XSDModelBuilder(URI schemaURI) throws IOException, TemplateBuilderException {
- loadSchema(schemaURI);
- }
-
- public Set<String> getRootElementNames() {
- return Collections.unmodifiableSet(elements.keySet());
- }
-
- public void setRootElementName(String rootElementName) {
- this.rootElementName = rootElementName;
- }
-
- public Document buildModel() throws TemplateBuilderException {
- if(rootElementName == null) {
- throw new IllegalStateException("The 'rootElementName' property
has not been set."); //$NON-NLS-1$
- }
-
- XSDElementDeclaration rootElement = elements.get(rootElementName);
-
- if(rootElement == null) {
- throw new IllegalArgumentException("Unknown root element '" +
rootElementName + "'."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- Document model = createModelInstance();
- expand(rootElement, 1, 1, model, model);
-
- return model;
- }
-
- private void loadSchema(URI baseURI, String schemaLocation) throws IOException,
TemplateBuilderException {
- File baseFile = new File(baseURI.toFileString());
- java.net.URI resolvedURI = baseFile.toURI().resolve(schemaLocation);
- File schemaFile = new File(resolvedURI);
-
- loadSchema(URI.createFileURI(schemaFile.getAbsolutePath()));
- }
-
- private void loadSchema(URI schemaURI) throws IOException, TemplateBuilderException
{
- if(loadedSchemas.contains(schemaURI.toFileString())) {
- return;
- }
-
- loadedSchemas.add(schemaURI.toFileString());
-
- Resource resource = new XSDResourceFactoryImpl().createResource(schemaURI);
- Map<String, Object> options = new HashMap<String, Object>();
-
- options.put(XSDResourceImpl.XSD_TRACK_LOCATION, true);
-
- resource.load(options);
-
- if(resource.getContents().isEmpty()) {
- throw new TemplateBuilderException("Failed to load schema '" +
schemaURI + "'."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- XSDSchema schema = (XSDSchema) resource.getContents().get(0);
-
- List<XSDElementDeclaration> elementDeclarations =
schema.getElementDeclarations();
- for(XSDElementDeclaration elementDeclaration : elementDeclarations) {
- if(!elementDeclaration.isAbstract()) {
- elements.put(elementDeclaration.getName(), elementDeclaration);
- }
- }
-
- EList typeDefs = schema.getTypeDefinitions();
- for(int i = 0; i < typeDefs.size(); i++) {
- XSDTypeDefinition type = (XSDTypeDefinition) typeDefs.get(i);
- types.put(type.getName(), type);
- }
-
- // Load includes and imports types...
- List contents = schema.getContents();
- for(Object schemaComponentObj : contents) {
- if(schemaComponentObj instanceof XSDImport) {
- XSDImport xsdImport = (XSDImport) schemaComponentObj;
- loadSchema(schemaURI, xsdImport.getSchemaLocation());
- } else if(schemaComponentObj instanceof XSDInclude) {
- XSDInclude xsdInclude = (XSDInclude) schemaComponentObj;
- loadSchema(schemaURI, xsdInclude.getSchemaLocation());
- }
- }
- }
-
- private void expand(XSDElementDeclaration elementDeclaration, int minOccurs, int
maxOccurs, Node parent, Document document) {
- XSDTypeDefinition typeDef;
-
- if(elementDeclaration.isElementDeclarationReference()) {
- elementDeclaration = elementDeclaration.getResolvedElementDeclaration();
- typeDef = elementDeclaration.getTypeDefinition();
- } else {
- typeDef = elementDeclaration.getTypeDefinition();
- }
-
- if(elementDeclaration.isAbstract()) {
- if(typeDef == null) {
- addTypeImpls(typeDef, minOccurs, maxOccurs, parent, document);
- }
- return;
- }
-
- if(elementExpandStack.contains(typeDef)) {
- return;
- }
-
- elementExpandStack.push(typeDef);
- try {
- String elementNS = elementDeclaration.getTargetNamespace();
- Element element;
-
- String elementName = elementDeclaration.getQName();
- if(elementNS != null) {
- element = document.createElementNS(elementNS, elementName);
- } else {
- element = document.createElement(elementName);
- }
-
- setMinMax(element, minOccurs, maxOccurs);
- parent.appendChild(element);
-
- if(typeDef instanceof XSDComplexTypeDefinition) {
- processComplexType(document, element, (XSDComplexTypeDefinition)
typeDef);
- } else if(typeDef instanceof XSDSimpleTypeDefinition) {
- XSDSimpleTypeDefinition simpleTypeDef = (XSDSimpleTypeDefinition)
typeDef;
- XSDTypeDefinition loadedType = types.get(simpleTypeDef.getName());
-
- if(loadedType instanceof XSDComplexTypeDefinition) {
- processComplexType(document, element, (XSDComplexTypeDefinition)
loadedType);
- }
- } else if(typeDef != null) {
- System.out.println("?? " + typeDef); //$NON-NLS-1$
- }
- } finally {
- elementExpandStack.pop();
- }
- }
-
- private void processComplexType(Document document, Element element,
XSDComplexTypeDefinition complexTypeDef) {
- XSDParticle particle = complexTypeDef.getComplexType();
- EList attributes = complexTypeDef.getAttributeContents();
-
- addAttributes(element, attributes);
-
- if(particle != null) {
- XSDParticleContent particleContent = particle.getContent();
- if (particleContent instanceof XSDModelGroup) {
- processModelGroup((XSDModelGroup) particleContent,
particle.getMinOccurs(), particle.getMaxOccurs(), element, document);
- }
- }
- }
-
- private void processModelGroup(XSDModelGroup modelGroup, int minOccurs, int
maxOccurs, Element element, Document document) {
- List<XSDParticle> particles = modelGroup.getParticles();
- XSDCompositor compositor = modelGroup.getCompositor();
- String compositorType = compositor.getName();
-
- if(particles.size() > 1 && compositorType.equals("choice"))
{ //$NON-NLS-1$
- Element composite = document.createElementNS(NAMESPACE,
"smk:composite"); //$NON-NLS-1$
-
- composite.setAttribute("type", compositorType); //$NON-NLS-1$
- setMinMax(composite, minOccurs, maxOccurs);
- element.appendChild(composite);
- element = composite;
- }
-
- for (XSDParticle particle : particles) {
- XSDParticleContent content = particle.getContent();
-
- if (content instanceof XSDElementDeclaration) {
- expand((XSDElementDeclaration) content, particle.getMinOccurs(),
particle.getMaxOccurs(), element, document);
- } else if (content instanceof XSDModelGroup) {
- processModelGroup((XSDModelGroup) content, particle.getMinOccurs(),
particle.getMaxOccurs(), element, document);
- }
- }
- }
-
- private void addTypeImpls(XSDTypeDefinition baseType, int minOccurs, int maxOccurs,
Node parent, Document document) {
- Set<Map.Entry<String, XSDElementDeclaration>> elementEntrySet =
elements.entrySet();
-
- for(Map.Entry<String, XSDElementDeclaration> elementEntry :
elementEntrySet) {
- XSDElementDeclaration elementDecl = elementEntry.getValue();
-
- if(isInstanceOf(baseType, elementDecl.getType())) {
- expand(elementDecl, minOccurs, maxOccurs, parent, document);
- }
- }
- }
-
- private void addAttributes(Element element, EList attributes) {
- // Add the attributes...
- if(attributes != null) {
- for(int i = 0; i < attributes.size(); i++) {
- XSDAttributeUse attributeUse = (XSDAttributeUse) attributes.get(i);
- XSDAttributeDeclaration attributeDecl =
attributeUse.getAttributeDeclaration();
- String name = attributeDecl.getQName();
- String attributeNS = attributeDecl.getTargetNamespace();
- String value = ""; //$NON-NLS-1$
- XSDAttributeUseCategory use = attributeUse.getUse();
-
- if(use == XSDAttributeUseCategory.REQUIRED_LITERAL) {
- value = REQUIRED;
- } else if(attributeUse.getValue() != null) {
- value = OPTIONAL + "=" +
attributeUse.getValue().toString(); //$NON-NLS-1$
- } else {
- value = OPTIONAL;
- }
-
- if(attributeNS != null) {
- element.setAttributeNS(attributeNS, name, value);
- } else {
- element.setAttribute(name, value);
- }
- }
- }
- }
-
- private boolean isInstanceOf(XSDTypeDefinition baseType, XSDTypeDefinition type) {
- if(type == null) {
- return false;
- } else if(type.equals(baseType)) {
- return true;
- } else if(type.equals(type.getBaseType())) {
- // The base type is equal to the type itself when we've reached the root
of the inheritance hierarchy...
- return false;
- } else {
- return isInstanceOf(baseType, type.getBaseType());
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDToFreemarkerTemplateBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDToFreemarkerTemplateBuilder.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/template/xsd/XSDToFreemarkerTemplateBuilder.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.template.xsd;
-
-import org.w3c.dom.Document;
-import org.milyn.xml.XmlUtil;
-import org.jboss.template.*;
-import org.jboss.template.exception.TemplateBuilderException;
-
-/**
- * Freemarker Template Buidler for a XSD messages.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class XSDToFreemarkerTemplateBuilder extends TemplateBuilder {
-
- public XSDToFreemarkerTemplateBuilder(Document model) {
- super(model);
- }
-
- public String buildTemplate() throws TemplateBuilderException {
- // TODO...
- return XmlUtil.serialize(getModel(), true);
- }
-}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -28,11 +28,11 @@
import org.eclipse.gef.requests.CreationFactory;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.jboss.template.CollectionMapping;
-import org.jboss.template.Mapping;
-import org.jboss.template.TemplateBuilder;
-import org.jboss.template.csv.CSVFreeMarkerTemplateBuilder;
-import org.jboss.template.csv.CSVModelBuilder;
+import org.jboss.tools.smooks.templating.model.csv.CSVModelBuilder;
+import org.jboss.tools.smooks.templating.template.CollectionMapping;
+import org.jboss.tools.smooks.templating.template.Mapping;
+import org.jboss.tools.smooks.templating.template.TemplateBuilder;
+import org.jboss.tools.smooks.templating.template.csv.CSVFreeMarkerTemplateBuilder;
import org.jboss.tools.smooks.configuration.editors.actions.AbstractSmooksActionGrouper;
import org.jboss.tools.smooks.configuration.editors.actions.ISmooksActionGrouper;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
@@ -472,8 +472,7 @@
try {
if (contents != null) {
CSVModelBuilder modelBuilder = new CSVModelBuilder(fields);
- Document model = modelBuilder.buildModel();
- TemplateBuilder builder = new CSVFreeMarkerTemplateBuilder(model, seprator, quote,
contents);
+ TemplateBuilder builder = new CSVFreeMarkerTemplateBuilder(modelBuilder, seprator,
quote, contents);
List<Mapping> mappings = builder.getMappings();
mappingList.addAll(mappings);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerCSVContentGenerator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerCSVContentGenerator.java 2009-12-11
17:18:15 UTC (rev 19225)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerCSVContentGenerator.java 2009-12-11
19:51:00 UTC (rev 19226)
@@ -15,10 +15,11 @@
import java.util.List;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.jboss.template.csv.CSVFreeMarkerTemplateBuilder;
-import org.jboss.template.csv.CSVModelBuilder;
-import org.jboss.template.exception.InvalidMappingException;
-import org.jboss.template.exception.TemplateBuilderException;
+import org.jboss.tools.smooks.templating.model.ModelBuilderException;
+import org.jboss.tools.smooks.templating.model.csv.CSVModelBuilder;
+import org.jboss.tools.smooks.templating.template.csv.CSVFreeMarkerTemplateBuilder;
+import org.jboss.tools.smooks.templating.template.exception.InvalidMappingException;
+import org.jboss.tools.smooks.templating.template.exception.TemplateBuilderException;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
@@ -35,9 +36,13 @@
*
*/
public class FreemarkerCSVContentGenerator {
+
+ public FreemarkerCSVContentGenerator() {
+ //empty constructor
+ }
public String generateCSVContents(FreemarkerCSVNodeGraphicalModel
csvRecordGraphicalModel)
- throws TemplateBuilderException {
+ throws TemplateBuilderException, ModelBuilderException {
// CSVNodeModel csvRecordModel = (CSVNodeModel)
// csvRecordGraphicalModel.getData();
@@ -88,10 +93,11 @@
}
CSVModelBuilder modelBuilder = new CSVModelBuilder(fieldsName.toArray(new String[]
{}));
- Document model = modelBuilder.buildModel();
CSVFreeMarkerTemplateBuilder builder;
+ Document model;
- builder = new CSVFreeMarkerTemplateBuilder(model, sperator, quote);
+ builder = new CSVFreeMarkerTemplateBuilder(modelBuilder, sperator, quote);
+ model = builder.getModel();
List<TreeNodeConnection> connections =
csvRecordGraphicalModel.getTargetConnections();
if (!connections.isEmpty() && connections.size() == 1) {