Author: DartPeng
Date: 2009-11-27 03:23:38 -0500 (Fri, 27 Nov 2009)
New Revision: 18871
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksSAXXMLHandler.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksXMLParserPool.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/AbstractAnyType.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/impl/AbstractAnyTypeImpl.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean/impl/JavabeanPackageImpl.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean12/impl/Javabean12PackageImpl.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/impl/SmooksPackageImpl.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceFactoryImpl.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceImpl.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksResourceFactoryImpl.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java
Log:
JBIDE-5157
DONE
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksSAXXMLHandler.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksSAXXMLHandler.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksSAXXMLHandler.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.core;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.xmi.XMLHelper;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+import org.jboss.tools.smooks.model.common.AbstractAnyType;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksSAXXMLHandler extends SAXXMLHandler {
+
+ public SmooksSAXXMLHandler(XMLResource xmiResource, XMLHelper helper, Map<?, ?>
options) {
+ super(xmiResource, helper, options);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.ecore.xmi.impl.XMLHandler#comment(char[], int, int)
+ */
+ @Override
+ public void comment(char[] ch, int start, int length) {
+ String comment = new String(ch, start, length);
+ Object obj = objects.get(objects.size() - 1);
+
+ if (mixedTargets.peek() != null) {
+ if (text != null) {
+ handleMixedText();
+ }
+ handleComment(comment);
+
+ } else {
+ // if (obj != null && obj instanceof AnyType) {
+ // FeatureMap featureMap = ((AnyType) obj).getMixed();
+ // if (featureMap != null) {
+ // try {
+ // featureMap.add(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT,
+ // comment);
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // }
+ // text = null;
+ // }
+ // }
+ if (obj != null && obj instanceof AbstractAnyType) {
+ int currentSize = ((AbstractAnyType) obj).eContents().size();
+ ((AbstractAnyType) obj).addComment(comment, new Integer(currentSize));
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.ecore.xmi.impl.XMLHandler#handleComment(java.lang.String)
+ */
+ @Override
+ protected void handleComment(String comment) {
+ FeatureMap featureMap = mixedTargets.peek();
+ featureMap.add(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT, comment);
+ text = null;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksSAXXMLHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksXMLParserPool.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksXMLParserPool.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksXMLParserPool.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.core;
+
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.emf.ecore.xmi.XMLDefaultHandler;
+import org.eclipse.emf.ecore.xmi.XMLHelper;
+import org.eclipse.emf.ecore.xmi.XMLLoad;
+import org.eclipse.emf.ecore.xmi.XMLParserPool;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksXMLParserPool implements XMLParserPool {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.ecore.xmi.XMLParserPool#get(java.util.Map,
+ * java.util.Map, boolean)
+ */
+ public SAXParser get(Map<String, Boolean> features, Map<String, ?>
properties, boolean useLexicalHandler)
+ throws ParserConfigurationException, SAXException {
+ SAXParserFactory f = SAXParserFactory.newInstance();
+ return f.newSAXParser();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.ecore.xmi.XMLParserPool#getDefaultHandler(org.eclipse
+ * .emf.ecore.xmi.XMLResource, org.eclipse.emf.ecore.xmi.XMLLoad,
+ * org.eclipse.emf.ecore.xmi.XMLHelper, java.util.Map)
+ */
+ public XMLDefaultHandler getDefaultHandler(XMLResource resource, XMLLoad xmlLoad,
XMLHelper helper,
+ Map<?, ?> options) {
+ return new SmooksSAXXMLHandler(resource, helper, options);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.ecore.xmi.XMLParserPool#release(javax.xml.parsers.SAXParser
+ * , java.util.Map, java.util.Map, boolean)
+ */
+ public void release(SAXParser parser, Map<String, Boolean> features,
Map<String, ?> properties,
+ boolean useLexicalHandler) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.ecore.xmi.XMLParserPool#releaseDefaultHandler(org.eclipse
+ * .emf.ecore.xmi.XMLDefaultHandler, java.util.Map)
+ */
+ public void releaseDefaultHandler(XMLDefaultHandler handler, Map<?, ?> options) {
+
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/SmooksXMLParserPool.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/AbstractAnyType.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/AbstractAnyType.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/AbstractAnyType.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -6,8 +6,9 @@
*/
package org.jboss.tools.smooks.model.common;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
-
import org.eclipse.emf.ecore.xml.type.AnyType;
/**
@@ -21,6 +22,17 @@
* @generated
*/
public interface AbstractAnyType extends EObject, AnyType {
+
+ public static final Object NULL_OBJECT = new Object();
+
+ Integer getCommentIndex(String comment);
+
+ void setCommentIndex(String comment , Integer index);
+
+ void addComment(String comment , Integer index);
+
+ List<String> getCommentList();
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/impl/AbstractAnyTypeImpl.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/impl/AbstractAnyTypeImpl.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/impl/AbstractAnyTypeImpl.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -6,6 +6,10 @@
*/
package org.jboss.tools.smooks.model.common.impl;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl;
@@ -14,18 +18,63 @@
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>Abstract Any
Type</b></em>'.
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> An implementation of the model object '
+ * <em><b>Abstract Any Type</b></em>'. <!-- end-user-doc
-->
* <p>
* </p>
- *
+ *
* @generated
*/
public abstract class AbstractAnyTypeImpl extends AnyTypeImpl implements AbstractAnyType
{
+
+ protected List<String> commentsList = new ArrayList<String>();
+
+ protected Map<String, Integer> commentIndexMap = new HashMap<String,
Integer>();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.model.common.AbstractAnyType#addComment(java.lang
+ * .String, java.lang.Object)
+ */
+ public void addComment(String comment, Integer index) {
+ commentsList.add(comment);
+ setCommentIndex(comment, index);
+ }
+
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * @return the commentsList
+ */
+ public List<String> getCommentList() {
+ return commentsList;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.model.common.AbstractAnyType#getObjectAfterComment
+ * (java.lang.String)
+ */
+ public Integer getCommentIndex(String comment) {
+ return commentIndexMap.get(comment);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.model.common.AbstractAnyType#setObjectAfterCommecnt
+ * (java.lang.String, java.lang.Object)
+ */
+ public void setCommentIndex(String comment, Integer obj) {
+ commentIndexMap.put(comment, obj);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
protected AbstractAnyTypeImpl() {
@@ -33,8 +82,8 @@
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
@Override
@@ -43,8 +92,8 @@
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
public String getCDATA() {
@@ -52,8 +101,8 @@
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
public void setCDATA(String cdata) {
@@ -62,8 +111,8 @@
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
public String getStringValue() {
@@ -71,13 +120,13 @@
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
public void setStringValue(String stringValue) {
SmooksModelUtils.cleanTextToSmooksType(this);
SmooksModelUtils.appendTextToSmooksType(this, stringValue);
}
-
-} //AbstractAnyTypeImpl
+
+} // AbstractAnyTypeImpl
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean/impl/JavabeanPackageImpl.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean/impl/JavabeanPackageImpl.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean/impl/JavabeanPackageImpl.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -724,7 +724,7 @@
source,
new String[] {
"name", "bindings_._type",
- "kind", "mixed"
+ "kind", "elementOnly"
});
addAnnotation
(getBindingsType_Group(),
@@ -932,7 +932,7 @@
source,
new String[] {
"name", "value_._type",
- "kind", "mixed"
+ "kind", "elementOnly"
});
addAnnotation
(getValueType_DecodeParam(),
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean12/impl/Javabean12PackageImpl.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean12/impl/Javabean12PackageImpl.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/javabean12/impl/Javabean12PackageImpl.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -768,7 +768,7 @@
source,
new String[] {
"name", "bean_._type",
- "kind", "mixed"
+ "kind", "elementOnly"
});
addAnnotation
(getBeanType_Group(),
@@ -1006,7 +1006,7 @@
source,
new String[] {
"name", "value_._type",
- "kind", "mixed"
+ "kind", "elementOnly"
});
addAnnotation
(getValueType_DecodeParam(),
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/impl/SmooksPackageImpl.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/impl/SmooksPackageImpl.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/impl/SmooksPackageImpl.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -1950,7 +1950,7 @@
source,
new String[] {
"name", "smooks-resource-list_._type",
- "kind", "mixed"
+ "kind", "elementOnly"
});
addAnnotation
(getSmooksResourceListType_Params(),
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceFactoryImpl.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceFactoryImpl.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceFactoryImpl.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -13,6 +13,7 @@
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.jboss.tools.smooks.core.SmooksXMLParserPool;
/**
* <!-- begin-user-doc -->
@@ -50,6 +51,7 @@
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER,
Boolean.TRUE);
+ result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_PARSER_POOL, new
SmooksXMLParserPool());
return result;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceImpl.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceImpl.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/util/SmooksResourceImpl.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -6,27 +6,95 @@
*/
package org.jboss.tools.smooks.model.smooks.util;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
-
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.DOMHandler;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
+import org.w3c.dom.Document;
/**
- * <!-- begin-user-doc -->
- * The <b>Resource </b> associated with the package.
+ * <!-- begin-user-doc --> The <b>Resource </b> associated with the
package.
* <!-- end-user-doc -->
+ *
* @see org.jboss.tools.smooks.model.smooks.util.SmooksResourceFactoryImpl
* @generated
*/
public class SmooksResourceImpl extends XMLResourceImpl {
/**
- * Creates an instance of the resource.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param uri the URI of the new resource.
+ * Creates an instance of the resource. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @param uri
+ * the URI of the new resource.
* @generated
*/
public SmooksResourceImpl(URI uri) {
super(uri);
}
-} //SmooksResourceImpl
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doSave(java.io.OutputStream
+ * , java.util.Map)
+ */
+ @Override
+ public void doSave(OutputStream outputStream, Map<?, ?> options) throws
IOException {
+ super.doSave(outputStream, options);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#save(org.w3c.dom.Document,
+ * java.util.Map, org.eclipse.emf.ecore.xmi.DOMHandler)
+ */
+ @Override
+ public Document save(Document doc, Map<?, ?> options, DOMHandler handler) {
+ return super.save(doc, options, handler);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#save(java.util.Map)
+ */
+ @Override
+ public void save(Map<?, ?> options) throws IOException {
+// IResource resource = getResource(this);
+// if (resource != null && resource.exists() && (resource instanceof
IFile)) {
+// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+// doSave(outputStream, options);
+//
+// try {
+// ((IFile) resource).setContents(new
ByteArrayInputStream(outputStream.toByteArray()), true, false, null);
+// } catch (CoreException e) {
+// throw new IOException(e.getMessage());
+// }
+// } else {
+ super.save(options);
+// }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doSave(java.io.Writer,
+ * java.util.Map)
+ */
+ @Override
+ public void doSave(Writer writer, Map<?, ?> options) throws IOException {
+ super.doSave(writer, options);
+ }
+
+} // SmooksResourceImpl
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksResourceFactoryImpl.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksResourceFactoryImpl.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksResourceFactoryImpl.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -13,6 +13,7 @@
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.jboss.tools.smooks.core.SmooksXMLParserPool;
/**
* <!-- begin-user-doc -->
@@ -50,6 +51,7 @@
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER,
Boolean.TRUE);
+ result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_PARSER_POOL, new
SmooksXMLParserPool());
return result;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -20,6 +20,7 @@
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Path;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.emf.common.command.Command;
@@ -136,6 +137,7 @@
public SmooksReaderFormPage(String id, String title) {
super(id, title);
+ IResource resource;
}
@Override
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -17,6 +17,7 @@
import java.util.TimerTask;
import org.dom4j.Document;
+import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
@@ -66,6 +67,7 @@
import org.jboss.tools.smooks.configuration.validate.SmooksMarkerHelper;
import org.jboss.tools.smooks.configuration.validate.SmooksModelValidator;
import org.jboss.tools.smooks.model.calc.provider.CalcItemProviderAdapterFactory;
+import org.jboss.tools.smooks.model.common.AbstractAnyType;
import org.jboss.tools.smooks.model.common.provider.CommonItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.csv.provider.CsvItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.csv12.provider.Csv12ItemProviderAdapterFactory;
@@ -219,6 +221,8 @@
try {
SAXReader parser = new SAXReader();
Document doc = parser.read(outstream);
+ EObject rootModel = this.getSmooksModel();
+ fillComments(doc, rootModel);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
OutputFormat format = OutputFormat.createPrettyPrint();
writer = new XMLWriter(stream, format);
@@ -234,6 +238,53 @@
return null;
}
+ protected void fillComments(Document document, EObject rootModel) {
+ if (rootModel instanceof DocumentRoot) {
+ EObject rootElementModel = ((DocumentRoot) rootModel).getSmooksResourceList();
+ Element rootElement = document.getRootElement();
+ try {
+ fillComments(rootElementModel, rootElement);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ protected void fillComments(EObject rootElementModel, Element rootElement) {
+ if (rootElementModel instanceof AbstractAnyType) {
+ List<String> comments = ((AbstractAnyType) rootElementModel).getCommentList();
+ for (Iterator<?> iterator = comments.iterator(); iterator.hasNext();) {
+ String string = (String) iterator.next();
+ Integer commentIndex = ((AbstractAnyType) rootElementModel).getCommentIndex(string);
+ List<?> content = rootElement.elements();
+ List<Object> deletedElementList = new ArrayList<Object>();
+ if (commentIndex.intValue() < content.size()) {
+ List<Object> tempelements = new ArrayList<Object>(content);
+ for (int i = commentIndex.intValue(); i < content.size(); i++) {
+ Element deleteObj = (Element) tempelements.get(i);
+ if (rootElement.remove(deleteObj)) {
+ deletedElementList.add(deleteObj);
+ }
+ }
+ }
+ rootElement.addComment(string);
+ for (int j = 0; j < deletedElementList.size(); j++) {
+ Element deleteElement = (Element) deletedElementList.get(j);
+ rootElement.add(deleteElement);
+ }
+ }
+
+ List<EObject> childrenModel = ((AbstractAnyType) rootElementModel).eContents();
+ List<?> elements = rootElement.elements();
+ int length = Math.min(childrenModel.size(), elements.size());
+ for (int index = 0; index < length; index++) {
+ EObject child = childrenModel.get(index);
+ Element childElement = (Element) elements.get(index);
+ fillComments(child, childElement);
+ }
+ }
+ }
+
protected String getFormattedXMLContents(String contents) throws IOException {
InputStream istream = null;
ByteArrayOutputStream stream = null;
@@ -581,6 +632,7 @@
smooksResource = new
SmooksResourceFactoryImpl().createResource(URI.createFileURI(filePath));
}
try {
+
smooksResource.load(Collections.emptyMap());
smooksModel = smooksResource.getContents().get(0);
} catch (IOException e) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java 2009-11-27
06:43:16 UTC (rev 18870)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java 2009-11-27
08:23:38 UTC (rev 18871)
@@ -28,6 +28,7 @@
public void analyzeTaskNode(ProcessType process, SmooksResourceListType resourceList) {
process.getTask().clear();
+ if(resourceList == null) return;
// Input task node must be in process:
TaskType inputTask = ProcessFactory.eINSTANCE.createTaskType();
inputTask.setId(TaskTypeManager.TASK_ID_INPUT);