Author: DartPeng
Date: 2009-08-18 05:19:10 -0400 (Tue, 18 Aug 2009)
New Revision: 17122
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataPathWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12MappingDataPathWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12UICreator.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.runtime/plugin.properties
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVInputDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
Log:
JBIDE-4774
Creat new EDI 1.2 reader wizard
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.runtime/plugin.properties
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.runtime/plugin.properties 2009-08-18
08:51:27 UTC (rev 17121)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.runtime/plugin.properties 2009-08-18
09:19:10 UTC (rev 17122)
@@ -1,2 +1,2 @@
-pluginName=Smooks Runtime 1.1.2 Plug-in
+pluginName=Smooks Runtime Plug-in
providerName=JBoss by Red Hat
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java 2009-08-18
08:51:27 UTC (rev 17121)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -32,6 +32,7 @@
import org.jboss.tools.smooks.configuration.editors.edi.SegmentsUICreator;
import org.jboss.tools.smooks.configuration.editors.edi.SubComponentUICreator;
import org.jboss.tools.smooks.configuration.editors.edireader.EDIReaderUICreator;
+import org.jboss.tools.smooks.configuration.editors.edireader12.EDIReader12UICreator;
import
org.jboss.tools.smooks.configuration.editors.esbrouter.RouteBeanPropertyUICreator;
import org.jboss.tools.smooks.configuration.editors.filerouting.HighWaterMarkUICreator;
import org.jboss.tools.smooks.configuration.editors.filerouting.OutputStreamUICreator;
@@ -98,6 +99,7 @@
import org.jboss.tools.smooks.model.dbrouting.impl.ResultSetImpl;
import org.jboss.tools.smooks.model.dbrouting.impl.ResultSetRowSelectorImpl;
import org.jboss.tools.smooks.model.edi.impl.EDIReaderImpl;
+import org.jboss.tools.smooks.model.edi12.impl.EDI12ReaderImpl;
import org.jboss.tools.smooks.model.esbrouting.impl.RouteBeanImpl;
import org.jboss.tools.smooks.model.fileRouting.impl.HighWaterMarkImpl;
import org.jboss.tools.smooks.model.fileRouting.impl.OutputStreamImpl;
@@ -315,6 +317,9 @@
map.put(BindingImpl.class, new Csv12ReaderBindingPropertyUICreator());
map.put(MapBindingImpl.class, new Csv12ReaderMapBindingPropertyUICreator());
+ // for EDI Reader v1.2
+ map.put(EDI12ReaderImpl.class, new EDIReader12UICreator());
+
// for Rules v1.0
map.put(RuleBaseImpl.class, new Rules10RulebaseUICreator());
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVInputDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVInputDataWizard.java 2009-08-18
08:51:27 UTC (rev 17121)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVInputDataWizard.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -9,6 +9,7 @@
import java.util.Properties;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -22,6 +23,7 @@
import
org.jboss.tools.smooks.configuration.editors.csv.CSVDataConfigurationWizardPage.FieldString;
import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
import org.jboss.tools.smooks.model.csv.CsvFactory;
+import org.jboss.tools.smooks.model.csv.CsvPackage;
import org.jboss.tools.smooks.model.csv.CsvReader;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
@@ -110,8 +112,9 @@
}
reader.setFields(fields);
- Command command = AddCommand.create(editingDomain, resourceList,
SmooksPackage.eINSTANCE
- .getSmooksResourceListType_AbstractReader(), reader);
+ Command command = AddCommand.create(editingDomain, resourceList,
+ SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil
+ .createEntry(CsvPackage.Literals.CSV_DOCUMENT_ROOT__READER, reader));
editingDomain.getCommandStack().execute(command);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-08-18
08:51:27 UTC (rev 17121)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -16,12 +16,10 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;
-import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
import org.dom4j.DocumentException;
@@ -33,16 +31,15 @@
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.XMLObjectAnalyzer;
import org.jboss.tools.smooks.model.edi.EDIReader;
+import org.jboss.tools.smooks.model.edi12.EDI12Reader;
import org.jboss.tools.smooks.model.graphics.ext.InputType;
import org.jboss.tools.smooks.model.graphics.ext.ParamType;
import org.jboss.tools.smooks.model.smooks.AbstractReader;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
import org.milyn.Smooks;
-import org.milyn.SmooksUtil;
-import org.milyn.cdr.SmooksResourceConfiguration;
-import org.milyn.smooks.edi.SmooksEDIReader;
-import org.milyn.xml.XmlUtil;
-import org.w3c.dom.Document;
+import org.milyn.payload.StringResult;
+import org.milyn.smooks.edi.EDIReaderConfigurator;
/**
* @author Dart
@@ -54,12 +51,16 @@
public static final String ENCODING = "encoding";
public static final Object MAPPING_MODEL = "mappingModelFile";
-
- public TagList parseEDIFile(InputStream stream, InputType
inputType,SmooksResourceListType resourceList , IProject project)
- throws IOException, DocumentException {
+
+ public static final Object VALIDATE = "validate";
+
+ public TagList parseEDIFile(InputStream stream, InputType inputType,
SmooksResourceListType resourceList,
+ IProject project) throws IOException, DocumentException {
List<ParamType> paramList = inputType.getParam();
String encoding = null;
String mappingModel = null;
+ String validate = null;
+ String type = inputType.getType();
for (Iterator<?> iterator = paramList.iterator(); iterator.hasNext();) {
ParamType paramType = (ParamType) iterator.next();
@@ -70,12 +71,18 @@
int index = -1;
for (Iterator<?> iterator2 = readers.iterator(); iterator2.hasNext();) {
AbstractReader abstractReader = (AbstractReader) iterator2.next();
- if (abstractReader instanceof EDIReader) {
+ if (abstractReader instanceof EDIReader &&
SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(type)) {
count++;
if (index == -1) {
index = readers.indexOf(abstractReader);
}
}
+ if (abstractReader instanceof EDI12Reader &&
SmooksModelUtils.INPUT_TYPE_EDI_1_2.equals(type)) {
+ count++;
+ if (index == -1) {
+ index = readers.indexOf(abstractReader);
+ }
+ }
}
if (count > 1) {
@@ -83,7 +90,7 @@
// RuntimeException("The smooks config file should have only one JSON
reader");
}
if (index != -1) {
- return parseEDIFile(stream, (EDIReader) readers.get(index) , project);
+ return parseEDIFile(stream, (EObject) readers.get(index), project);
}
}
@@ -96,7 +103,7 @@
}
}
- return parseEDIFile(stream, mappingModel, encoding, project);
+ return parseEDIFile(stream, mappingModel, encoding,validate, project);
}
public TagList parseEDIFile(InputStream stream, InputType inputType,
SmooksResourceListType resourceList)
@@ -105,6 +112,8 @@
List<ParamType> paramList = inputType.getParam();
String encoding = null;
String mappingModel = null;
+ String validate = null;
+ String type = inputType.getType();
for (Iterator<?> iterator = paramList.iterator(); iterator.hasNext();) {
ParamType paramType = (ParamType) iterator.next();
@@ -115,12 +124,18 @@
int index = -1;
for (Iterator<?> iterator2 = readers.iterator(); iterator2.hasNext();) {
AbstractReader abstractReader = (AbstractReader) iterator2.next();
- if (abstractReader instanceof EDIReader) {
+ if (abstractReader instanceof EDIReader &&
SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(type)) {
count++;
if (index == -1) {
index = readers.indexOf(abstractReader);
}
}
+ if (abstractReader instanceof EDI12Reader &&
SmooksModelUtils.INPUT_TYPE_EDI_1_2.equals(type)) {
+ count++;
+ if (index == -1) {
+ index = readers.indexOf(abstractReader);
+ }
+ }
}
if (count > 1) {
@@ -128,7 +143,7 @@
// RuntimeException("The smooks config file should have only one JSON
reader");
}
if (index != -1) {
- return parseEDIFile(stream, (EDIReader) readers.get(index));
+ return parseEDIFile(stream, (EObject) readers.get(index));
}
}
@@ -139,39 +154,69 @@
if (paramType.getName().equals(MAPPING_MODEL)) {
mappingModel = paramType.getValue();
}
+ if (paramType.getName().equals(VALIDATE)) {
+ validate = paramType.getValue();
+ }
}
- return parseEDIFile(stream, mappingModel, encoding, resourceList);
+ return parseEDIFile(stream, mappingModel, encoding,validate, resourceList);
}
- public TagList parseEDIFile(InputStream ediInputStream, EDIReader reader , IProject
project) throws IOException, DocumentException {
- String encoding = reader.getEncoding();
- String mappingModel = reader.getMappingModel();
- return parseEDIFile(ediInputStream, mappingModel, encoding, project);
+
+ public TagList parseEDIFile(InputStream ediInputStream, EObject readerObj, IProject
project) throws IOException,
+ DocumentException {
+ String encoding = null;
+ String mappingModel = null;
+ String validate = null;
+ if(readerObj instanceof EDIReader){
+ EDIReader reader = (EDIReader)readerObj;
+ encoding = reader.getEncoding();
+ mappingModel = reader.getMappingModel();
+ }
+ if(readerObj instanceof EDI12Reader){
+ EDI12Reader reader = (EDI12Reader)readerObj;
+ encoding = reader.getEncoding();
+ mappingModel = reader.getMappingModel();
+ }
+ return parseEDIFile(ediInputStream, mappingModel, encoding,validate, project);
}
- public TagList parseEDIFile(InputStream ediInputStream, EDIReader reader) throws
IOException, DocumentException {
- String encoding = reader.getEncoding();
- String mappingModel = reader.getMappingModel();
- return parseEDIFile(ediInputStream, mappingModel, encoding, reader);
+ public TagList parseEDIFile(InputStream ediInputStream, EObject readerObj) throws
IOException, DocumentException {
+
+ String encoding = null;
+ String mappingModel = null;
+ if(readerObj instanceof EDIReader){
+ EDIReader reader = (EDIReader)readerObj;
+ encoding = reader.getEncoding();
+ mappingModel = reader.getMappingModel();
+ }
+ if(readerObj instanceof EDI12Reader){
+ EDI12Reader reader = (EDI12Reader)readerObj;
+ encoding = reader.getEncoding();
+ mappingModel = reader.getMappingModel();
+ }
+ return parseEDIFile(ediInputStream, mappingModel, encoding,null,(EObject) readerObj);
}
- public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String
ediFileEncoding, EObject emodel)
+ public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String
ediFileEncoding, String validate , EObject emodel)
throws IOException, DocumentException {
IResource resource = SmooksUIUtils.getResource(emodel);
IProject project = null;
if (resource != null) {
project = resource.getProject();
}
- return parseEDIFile(ediInputStream, mappingModel, ediFileEncoding, project);
+ return parseEDIFile(ediInputStream, mappingModel, ediFileEncoding,validate, project);
}
public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String
ediFileEncoding,
- IProject project) throws IOException, DocumentException {
+ String validate, IProject project) throws IOException, DocumentException {
Smooks smooks = new Smooks();
- SmooksResourceConfiguration readerConfig = new
SmooksResourceConfiguration("org.xml.sax.driver",
- SmooksEDIReader.class.getName());
- if(mappingModel == null) return null;
+// SmooksResourceConfiguration readerConfig = new
SmooksResourceConfiguration("org.xml.sax.driver",
+// SmooksEDIReader.class.getName());
+
+ if (mappingModel == null)
+ return null;
+
File f = new File(mappingModel);
String modelPath = mappingModel;
if (f.exists()) {
@@ -182,41 +227,30 @@
modelPath = tf.getLocation().toFile().toURI().toString();
}
}
-
- readerConfig.setParameter("mapping-model", modelPath);
+ EDIReaderConfigurator readerConfig = new EDIReaderConfigurator(modelPath);
if (ediFileEncoding == null || ediFileEncoding.trim().length() == 0) {
ediFileEncoding = "UTF-8";
}
- readerConfig.setParameter("encoding", ediFileEncoding);
+// readerConfig.
+// readerConfig.setParameter("encoding", ediFileEncoding);
- SmooksUtil.registerResource(readerConfig, smooks);
+ smooks.setReaderConfig(readerConfig);
+// SmooksUtil.registerResource(readerConfig, smooks);
// Use a DOM result to capture the message model for the supplied
// CSV
// message...
- DOMResult domResult = new DOMResult();
// Filter the message through Smooks and capture the result as a DOM
// in
// the domResult instance...
// FileInputStream stream
- smooks.filter(new StreamSource(ediInputStream), domResult);
+ StringResult result = new StringResult();
+ smooks.filterSource(new StreamSource(ediInputStream), result);
- // Get the Document object from the domResult. This is the message
- // model!!!...
- Document model = (Document) domResult.getNode();
- // So using the model Document, you can construct a tree structure
- // for
- // the editor.
-
- // We'll just print out the model DOM here so you can see it....
- StringWriter modelWriter = new StringWriter();
- // System.out.println(modelWriter);
- XmlUtil.serialize(model, true, modelWriter);
-
XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
- ByteArrayInputStream byteinputStream = new
ByteArrayInputStream(modelWriter.toString().getBytes());
+ ByteArrayInputStream byteinputStream = new
ByteArrayInputStream(result.getResult().getBytes());
TagList tagList = analyzer.analyze(byteinputStream, null);
try {
@@ -224,10 +258,6 @@
byteinputStream.close();
byteinputStream = null;
}
- if (modelWriter != null) {
- modelWriter.close();
- modelWriter = null;
- }
if (smooks != null) {
smooks.close();
smooks = null;
@@ -236,7 +266,7 @@
ediInputStream.close();
ediInputStream = null;
}
- model = null;
+ result = null;
} catch (Throwable t) {
t.printStackTrace();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataWizard.java 2009-08-18
08:51:27 UTC (rev 17121)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataWizard.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -13,6 +13,7 @@
import java.util.Properties;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -26,6 +27,7 @@
import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
import org.jboss.tools.smooks.model.edi.EDIReader;
import org.jboss.tools.smooks.model.edi.EdiFactory;
+import org.jboss.tools.smooks.model.edi.EdiPackage;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
@@ -71,8 +73,9 @@
EDIReader reader = EdiFactory.eINSTANCE.createEDIReader();
reader.setEncoding(encoding);
reader.setMappingModel(path);
- Command command = AddCommand.create(editingDomain, resourceList,
SmooksPackage.eINSTANCE
- .getSmooksResourceListType_AbstractReader(), reader);
+ Command command = AddCommand.create(editingDomain, resourceList,
+ SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil
+ .createEntry(EdiPackage.Literals.EDI_DOCUMENT_ROOT__READER, reader));
editingDomain.getCommandStack().execute(command);
}
return true;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java 2009-08-18
08:51:27 UTC (rev 17121)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader/EDIReaderUICreator.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -17,7 +17,6 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.AttributeFieldEditPart;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
-import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.edimap.editor.EDIMapFormEditor;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataPathWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataPathWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataPathWizardPage.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.configuration.editors.edireader12;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDIReader12DataPathWizardPage extends AbstractFileSelectionWizardPage {
+
+ public EDIReader12DataPathWizardPage(String pageName, boolean multiSelect, Object[]
initSelections,
+ List<ViewerFilter> filters) {
+ super(pageName, multiSelect, initSelections, filters);
+ }
+
+ public EDIReader12DataPathWizardPage(String pageName, String[] fileExtensionNames) {
+ super(pageName, fileExtensionNames);
+ this.setTitle("EDI file selection");
+ this.setDescription("Select a EDI data file");
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
+ */
+ @Override
+ protected Object loadedTheObject(String path) throws Exception {
+ return null;
+ }
+
+ @Override
+ protected void changeWizardPageStatus() {
+ super.changeWizardPageStatus();
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return super.canFlipToNextPage();
+// String filePath = this.getFilePath();
+// try {
+// filePath = SmooksUIUtils.parseFilePath(filePath);
+// if(filePath == null) return false;
+// return new File(filePath).exists();
+// } catch (InvocationTargetException e) {
+// return false;
+// }
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataPathWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataWizard.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * 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.configuration.editors.edireader12;
+
+import java.util.Properties;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+import org.jboss.tools.smooks.configuration.editors.edi.EDIDataParser;
+import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+import org.jboss.tools.smooks.model.edi12.EDI12Reader;
+import org.jboss.tools.smooks.model.edi12.Edi12Factory;
+import org.jboss.tools.smooks.model.edi12.Edi12Package;
+import org.jboss.tools.smooks.model.smooks.DocumentRoot;
+import org.jboss.tools.smooks.model.smooks.SmooksPackage;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @author Dart
+ *
+ */
+public class EDIReader12DataWizard extends Wizard implements
IStructuredDataSelectionWizard, INewWizard {
+
+ private EDIReader12MappingDataPathWizardPage mappingFilePage;
+
+ private EDIReader12DataPathWizardPage ediFilePage;
+
+ private SmooksResourceListType resourceList;
+
+ private EditingDomain editingDomain;
+
+ @Override
+ public void addPages() {
+ ediFilePage = new EDIReader12DataPathWizardPage("EDI Data Page", new String[]
{});
+ this.addPage(ediFilePage);
+
+ mappingFilePage = new EDIReader12MappingDataPathWizardPage("EDI Config Page",
null);
+ this.addPage(mappingFilePage);
+ super.addPages();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ if (mappingFilePage.isUseAvaliableReader()) {
+ return true;
+ }
+ if (mappingFilePage.isCreateNewReader()) {
+ String encoding = mappingFilePage.getEncoding();
+ String path = mappingFilePage.getFilePath();
+ String validate = mappingFilePage.getValidate();
+ EDI12Reader reader = Edi12Factory.eINSTANCE.createEDI12Reader();
+ reader.setEncoding(encoding);
+ reader.setMappingModel(path);
+ if (validate != null && validate.length() != 0) {
+ reader.setValidate(Boolean.valueOf(validate));
+ }
+ Command command = AddCommand.create(editingDomain, resourceList,
+ SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil
+ .createEntry(Edi12Package.Literals.EDI12_DOCUMENT_ROOT__READER, reader));
+ editingDomain.getCommandStack().execute(command);
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard
+ * #complate(org.jboss.tools.smooks.configuration
+ * .editors.SmooksMultiFormEditor)
+ */
+ public void complate(SmooksMultiFormEditor formEditor) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getInputDataTypeID()
+ */
+ public String getInputDataTypeID() {
+ return SmooksModelUtils.INPUT_TYPE_EDI_1_2;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getProperties()
+ */
+ public Properties getProperties() {
+ Properties pros = new Properties();
+ if (mappingFilePage.isUseAvaliableReader() || mappingFilePage.isCreateNewReader()) {
+ pros.put(EDIDataParser.USE_AVAILABEL_READER, "true");
+ return pros;
+ }
+ String encoding = mappingFilePage.getEncoding();
+ if (encoding != null && encoding.length() != 0) {
+ pros.put(EDIDataParser.ENCODING, encoding);
+ }
+
+ String path = mappingFilePage.getFilePath();
+ if(path != null && path.length() != 0){
+ pros.put(EDIDataParser.MAPPING_MODEL, path);
+ }
+
+ String validate = mappingFilePage.getValidate();
+ if(validate != null && validate.length() != 0){
+ pros.put(EDIDataParser.VALIDATE, validate);
+ }
+ return pros;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getReturnData()
+ */
+ public Object getReturnData() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getStructuredDataSourcePath()
+ */
+ public String getStructuredDataSourcePath() {
+ if (ediFilePage.getFilePath() != null) {
+ return ediFilePage.getFilePath();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
+ */
+ public void init(IEditorSite site, IEditorInput input) {
+ IEditorPart editorPart = site.getWorkbenchWindow().getActivePage().findEditor(input);
+ if (editorPart != null && editorPart instanceof SmooksMultiFormEditor) {
+ SmooksMultiFormEditor formEditor = (SmooksMultiFormEditor) editorPart;
+ Object smooksModel = formEditor.getSmooksModel();
+ if (smooksModel instanceof DocumentRoot) {
+ resourceList = ((DocumentRoot) smooksModel).getSmooksResourceList();
+ }
+ editingDomain = formEditor.getEditingDomain();
+ }
+ if (this.mappingFilePage != null) {
+ mappingFilePage.setSmooksResourceList(resourceList);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12DataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12MappingDataPathWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12MappingDataPathWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12MappingDataPathWizardPage.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -0,0 +1,297 @@
+/*******************************************************************************
+ * 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.configuration.editors.edireader12;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.configuration.editors.ClassPathFileProcessor;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage;
+import org.jboss.tools.smooks.model.edi12.EDI12Reader;
+import org.jboss.tools.smooks.model.edi12.impl.EDI12ReaderImpl;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDIReader12MappingDataPathWizardPage extends AbstractFileSelectionWizardPage
{
+
+ private boolean hasReader = false;
+
+ private boolean createNewReader = true;
+
+ private String mappingFile = null;
+
+ private Composite fileComposite = null;
+
+ private String encoding = "UTF-8";
+
+ private Button createNewReaderButton;
+
+ private boolean useAvaliableReader = false;
+
+ private String validate = null;
+
+ private SmooksResourceListType resourceList;
+
+ public EDIReader12MappingDataPathWizardPage(String pageName, boolean multiSelect,
Object[] initSelections,
+ List<ViewerFilter> filters) {
+ super(pageName, multiSelect, initSelections, filters);
+ this.setTitle("EDI Mapping file configuration (version 1.2)");
+ this.setDescription("Select a EDI mapping config file");
+ this.setFilePathProcessor(new ClassPathFileProcessor());
+ }
+
+ public EDIReader12MappingDataPathWizardPage(String pageName, String[]
fileExtensionNames) {
+ super(pageName, fileExtensionNames);
+ this.setTitle("EDI Mapping file configuration (version 1.2)");
+ this.setDescription("Select a EDI mapping config file");
+ this.setFilePathProcessor(new ClassPathFileProcessor());
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public boolean isUseAvaliableReader() {
+ return useAvaliableReader;
+ }
+
+ public SmooksResourceListType getSmooksResourceList() {
+ return resourceList;
+ }
+
+ public void setSmooksResourceList(SmooksResourceListType resourceList) {
+ this.resourceList = resourceList;
+ }
+
+ private void initData() {
+ encoding = "UTF-8";
+ validate = null;
+ hasReader = false;
+ useAvaliableReader = false;
+ createNewReader = true;
+ if (SmooksUIUtils.hasReaderAlready(EDI12Reader.class, resourceList)
+ || SmooksUIUtils.hasReaderAlready(EDI12ReaderImpl.class, resourceList)) {
+ hasReader = true;
+ }
+
+ mappingFile = null;
+
+ if (hasReader) {
+ useAvaliableReader = true;
+ createNewReader = false;
+ }
+ }
+
+ public boolean isHasReader() {
+ return hasReader;
+ }
+
+ public boolean isCreateNewReader() {
+ return createNewReader;
+ }
+
+ public String getValidate() {
+ return validate;
+ }
+
+ public void setValidate(String validate) {
+ this.validate = validate;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ initData();
+ super.createControl(parent);
+ }
+
+ public String getMappingFile() {
+ return mappingFile;
+ }
+
+ @Override
+ protected void createExtensionGUIFirst(Composite parent) {
+ Label encodingLabel = new Label(parent, SWT.NONE);
+ encodingLabel.setText("Encoding:");
+ final Text encodingText = new Text(parent, SWT.BORDER);
+ encodingText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ mappingFile = encodingText.getText();
+ }
+ });
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ encodingText.setLayoutData(gd);
+
+
+ Label validateLabel = new Label(parent, SWT.NONE);
+ validateLabel.setText("Validate:");
+ final Combo validateCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ validateCombo.add("");
+ validateCombo.add("TRUE");
+ validateCombo.add("FALSE");
+ validateCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validate = encodingText.getText();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ validateCombo.setLayoutData(gd);
+ }
+
+ @Override
+ protected Composite createFileSelectionComposite(Composite parent) {
+ Composite chooseComposite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ chooseComposite.setLayoutData(gd);
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ chooseComposite.setLayout(gl);
+
+ Button newReaderButton = new Button(chooseComposite, SWT.RADIO);
+ newReaderButton.setText("Create new EDI reader configurations");
+
+ final Button useReaderButton = new Button(chooseComposite, SWT.RADIO);
+ useReaderButton.setText("Use available EDI reader configurations");
+
+ fileComposite = super.createFileSelectionComposite(parent);
+
+ createNewReaderButton = new Button(fileComposite, SWT.CHECK);
+ createNewReaderButton.setText("Create New EDI Reader");
+ createNewReaderButton.setSelection(true);
+
+ if (hasReader) {
+ createNewReaderButton.setSelection(false);
+ createNewReaderButton.setEnabled(false);
+
+ useReaderButton.setSelection(true);
+ this.setConfigCompositeStates(false);
+ } else {
+ newReaderButton.setSelection(true);
+ createNewReaderButton.setSelection(true);
+ }
+
+ createNewReaderButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ createNewReader = createNewReaderButton.getSelection();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ newReaderButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ useAvaliableReader = useReaderButton.getSelection();
+ setConfigCompositeStates(true);
+ changeWizardPageStatus();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+ useReaderButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ useAvaliableReader = useReaderButton.getSelection();
+ setConfigCompositeStates(false);
+ changeWizardPageStatus();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ createNewReaderButton.setLayoutData(gd);
+ return fileComposite;
+ }
+
+ private void setConfigCompositeStates(boolean enabled) {
+ fileComposite.setEnabled(enabled);
+ Control[] controls = fileComposite.getChildren();
+ for (int i = 0; i < controls.length; i++) {
+ Control c = controls[i];
+ if (c == createNewReaderButton) {
+ if (hasReader) {
+ c.setEnabled(false);
+ continue;
+ }
+ }
+ if (c == fileTextComposite) {
+ Control[] cs = ((Composite) c).getChildren();
+ for (int j = 0; j < cs.length; j++) {
+ Control cc = cs[j];
+ cc.setEnabled(enabled);
+ }
+ }
+ c.setEnabled(enabled);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.
+ * AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
+ */
+ @Override
+ protected Object loadedTheObject(String path) throws Exception {
+ return null;
+ }
+
+ @Override
+ protected void changeWizardPageStatus() {
+ if (!useAvaliableReader) {
+ super.changeWizardPageStatus();
+ } else {
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return super.canFlipToNextPage();
+ // String filePath = this.getFilePath();
+ // try {
+ // filePath = SmooksUIUtils.parseFilePath(filePath);
+ // if(filePath == null) return false;
+ // return new File(filePath).exists();
+ // } catch (InvocationTargetException e) {
+ // return false;
+ // }
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12MappingDataPathWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12UICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12UICreator.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12UICreator.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.configuration.editors.edireader12;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.editors.AttributeFieldEditPart;
+import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.edimap.editor.EDIMapFormEditor;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.model.edi12.Edi12Package;
+
+/**
+ * @author Dart Peng (dpeng(a)redhat.com) Date Apr 10, 2009
+ */
+public class EDIReader12UICreator extends PropertyUICreator {
+
+ public EDIReader12UICreator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.IPropertyUICreator#
+ * createPropertyUI(org.eclipse.ui.forms.widgets.FormToolkit,
+ * org.eclipse.swt.widgets.Composite,
+ * org.eclipse.emf.edit.provider.IItemPropertyDescriptor, java.lang.Object,
+ * org.eclipse.emf.ecore.EAttribute)
+ */
+ public AttributeFieldEditPart createPropertyUI(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ ISmooksModelProvider formEditor, IEditorPart part) {
+ if (feature == Edi12Package.eINSTANCE.getEDI12Reader_Encoding()) {
+ }
+ if (feature == Edi12Package.eINSTANCE.getEDI12Reader_MappingModel()) {
+ return SmooksUIUtils.createFileSelectionTextFieldEditor(null, parent, null, toolkit,
propertyDescriptor,
+ model, SmooksUIUtils.VALUE_TYPE_VALUE, EDIMapFormEditor.EDITOR_ID, null);
+ }
+ return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor, part);
+ }
+
+ @Override
+ public boolean isFileSelectionFeature(EAttribute attribute) {
+ // if (attribute == EdiPackage.eINSTANCE.getEDIReader_MappingModel()) {
+ // return true;
+ // }
+ return super.isFileSelectionFeature(attribute);
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edireader12/EDIReader12UICreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java 2009-08-18
08:51:27 UTC (rev 17121)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -15,6 +15,7 @@
import java.util.Properties;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -29,6 +30,7 @@
import org.jboss.tools.smooks.configuration.editors.uitls.JsonInputDataParser;
import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
import org.jboss.tools.smooks.model.json.JsonFactory;
+import org.jboss.tools.smooks.model.json.JsonPackage;
import org.jboss.tools.smooks.model.json.JsonReader;
import org.jboss.tools.smooks.model.json.Key;
import org.jboss.tools.smooks.model.json.KeyMap;
@@ -146,8 +148,9 @@
if (ier != null && ier.length() != 0) {
reader.setIllegalElementNameCharReplacement(ier);
}
- Command command = AddCommand.create(editingDomain, resourceList,
SmooksPackage.eINSTANCE
- .getSmooksResourceListType_AbstractReader(), reader);
+ Command command = AddCommand.create(editingDomain, resourceList,
+ SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil
+ .createEntry(JsonPackage.Literals.JSON_DOCUMENT_ROOT__READER, reader));
editingDomain.getCommandStack().execute(command);
}
return true;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-08-18
08:51:27 UTC (rev 17121)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-08-18
09:19:10 UTC (rev 17122)
@@ -20,6 +20,7 @@
import org.jboss.tools.smooks.configuration.editors.csv.CSVInputDataWizard;
import org.jboss.tools.smooks.configuration.editors.csv12.CSV12InputDataWizard;
import org.jboss.tools.smooks.configuration.editors.edi.EDIDataWizard;
+import org.jboss.tools.smooks.configuration.editors.edireader12.EDIReader12DataWizard;
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanContentProvider;
import
org.jboss.tools.smooks.configuration.editors.javabean.JavabeanStrucutredDataWizard;
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanlabelProvider;
@@ -277,7 +278,24 @@
ediViewerInitor.setStructuredDataLoadWizard(new EDIDataWizard());
// jsonViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
map.put(typeID, ediViewerInitor);
+
+ // for EDI 1.2
+ BaseViewerInitor edi12ViewerInitor = new BaseViewerInitor();
+ name = "EDI 1.2";
+ description = "Select EDI data file as the input data. (version 1.2)";
+ iconPath = null;
+ typeID = SmooksModelUtils.INPUT_TYPE_EDI_1_2;
+ edi12ViewerInitor.setName(name);
+ edi12ViewerInitor.setDescription(description);
+ edi12ViewerInitor.setWizardIconPath(iconPath);
+ edi12ViewerInitor.setTypeID(typeID);
+ edi12ViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+ edi12ViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+ edi12ViewerInitor.setStructuredDataLoadWizard(new EDIReader12DataWizard());
+ // jsonViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
+ map.put(typeID, edi12ViewerInitor);
+
return map;
}