Author: DartPeng
Date: 2009-08-18 04:26:17 -0400 (Tue, 18 Aug 2009)
New Revision: 17119
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataConfiguraitonWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataPathWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataWizard.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv/CsvPackage.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv12/Csv12Package.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/json12/Json12Package.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12DataConfigurationWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12InputDataWizard.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/json/JsonDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java
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/edimap/editor/EDIMapFormPage.java
Log:
JBIDE-4774
Creat new JSON 1.2 reader
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv/CsvPackage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv/CsvPackage.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv/CsvPackage.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -54,7 +54,7 @@
* <!-- end-user-doc -->
* @generated
*/
- String eNS_PREFIX = "cvs";
+ String eNS_PREFIX = "csv";
/**
* The singleton instance of the package.
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv12/Csv12Package.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv12/Csv12Package.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/csv12/Csv12Package.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -55,7 +55,7 @@
* <!-- end-user-doc -->
* @generated
*/
- String eNS_PREFIX = "csv";
+ String eNS_PREFIX = "csv12";
/**
* The singleton instance of the package.
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/json12/Json12Package.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/json12/Json12Package.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/json12/Json12Package.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -56,7 +56,7 @@
* <!-- end-user-doc -->
* @generated
*/
- String eNS_PREFIX = "json";
+ String eNS_PREFIX = "json12";
/**
* The singleton instance of the package.
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -51,7 +51,7 @@
public static final String INPUT_TYPE_JAVA = "java";
- public static final String INPUT_TYPE_JSON = "json";
+ public static final String INPUT_TYPE_JSON_1_1 = "json";
public static final String INPUT_TYPE_CSV_1_1 = "csv";
@@ -75,8 +75,12 @@
public static final String BINDINGS = "bindings";
- public static final String INPUT_TYPE_EDI = "EDI";
+ public static final String INPUT_TYPE_EDI_1_1 = "EDI";
+ public static final String INPUT_TYPE_EDI_1_2 = "EDI_1_2";
+
+ public static final String INPUT_TYPE_JSON_1_2 = "json_1_2";
+
public static EStructuralFeature ATTRIBUTE_PROPERTY =
ExtendedMetaData.INSTANCE.demandFeature(null, "property",
false);
@@ -504,8 +508,9 @@
public static String getInputPath(InputType input) {
List<org.jboss.tools.smooks.model.graphics.ext.ParamType> list =
input.getParam();
if (INPUT_TYPE_JAVA.equals(input.getType()) || INPUT_TYPE_XML.equals(input.getType())
- || INPUT_TYPE_XSD.equals(input.getType()) || INPUT_TYPE_JSON.equals(input.getType())
- || INPUT_TYPE_CSV_1_1.equals(input.getType()) ||
INPUT_TYPE_EDI.equals(input.getType())
+ || INPUT_TYPE_XSD.equals(input.getType()) ||
INPUT_TYPE_JSON_1_1.equals(input.getType())
+ || INPUT_TYPE_JSON_1_2.equals(input.getType()) ||
INPUT_TYPE_CSV_1_1.equals(input.getType())
+ || INPUT_TYPE_EDI_1_1.equals(input.getType()) ||
INPUT_TYPE_EDI_1_2.equals(input.getType())
|| INPUT_TYPE_CSV_1_2.equals(input.getType())) {
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
org.jboss.tools.smooks.model.graphics.ext.ParamType paramType =
(org.jboss.tools.smooks.model.graphics.ext.ParamType) iterator
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -255,7 +255,8 @@
String path = SmooksModelUtils.getInputPath(inputType);
if (type != null && path != null) {
path = path.trim();
- if (SmooksModelUtils.INPUT_TYPE_EDI.equals(type)) {
+ if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(type)
+ || SmooksModelUtils.INPUT_TYPE_EDI_1_2.equals(type)) {
EDIDataParser parser = new EDIDataParser();
try {
TagList tl = parser.parseEDIFile(path, inputType, smooksResourceListType);
@@ -278,7 +279,8 @@
t.printStackTrace();
}
}
- if (SmooksModelUtils.INPUT_TYPE_JSON.equals(type)) {
+ if (SmooksModelUtils.INPUT_TYPE_JSON_1_1.equals(type)
+ || SmooksModelUtils.INPUT_TYPE_JSON_1_2.equals(type)) {
try {
JsonInputDataParser parser = new JsonInputDataParser();
IXMLStructuredObject tagList =
parser.parseJsonFile(SmooksUIUtils.parseFilePath(path),
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -15,6 +15,7 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
+import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.List;
@@ -223,6 +224,9 @@
if (recordName != null) {
readerConfigurator.setRecordElementName(recordName);
}
+
+ readerConfigurator.setEncoding(Charset.forName(encoding));
+// readerConfigurator.setIndent(indent)
smooks.setReaderConfig(readerConfigurator);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12DataConfigurationWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12DataConfigurationWizardPage.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12DataConfigurationWizardPage.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -35,6 +35,7 @@
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.Item;
@@ -89,6 +90,8 @@
private List<FieldString> fieldsList = new ArrayList<FieldString>();
private Text rootNameText;
private Text recordNameText;
+ private Combo indentText;
+ protected String indent;
public CSV12DataConfigurationWizardPage(String pageName, String title, ImageDescriptor
titleImage) {
super(pageName, title, titleImage);
@@ -179,6 +182,14 @@
skiplineLabel.setText("Skip Lines");
skipLinesText = new Text(configComposite, SWT.BORDER);
skipLinesText.setLayoutData(gd);
+
+ Label indentLabel = new Label(configComposite, SWT.NONE);
+ indentLabel.setText("Indent");
+ indentText = new Combo(configComposite, SWT.BORDER | SWT.READ_ONLY);
+ indentText.add("");
+ indentText.add("TRUE");
+ indentText.add("FALSE");
+ indentText.setLayoutData(gd);
Label encodingLabel = new Label(configComposite, SWT.NONE);
encodingLabel.setText("Encoding");
@@ -397,7 +408,15 @@
changePageStatus();
}
});
+
+ indentText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ indent = indentText.getText();
+ changePageStatus();
+ }
+ });
+
this.createCSVReaderButton.addSelectionListener(new SelectionListener() {
/*
@@ -558,6 +577,14 @@
}
}
+ public String getIndent() {
+ return indent;
+ }
+
+ public void setIndent(String indent) {
+ this.indent = indent;
+ }
+
/**
* @return the separator
*/
@@ -680,6 +707,8 @@
}
private void initValue() {
+ indent = null;
+
useAvailabelReader = false;
filePath = null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12InputDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12InputDataWizard.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv12/CSV12InputDataWizard.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -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;
@@ -21,9 +22,11 @@
import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.csv.CSVDataParser;
import
org.jboss.tools.smooks.configuration.editors.csv12.CSV12DataConfigurationWizardPage.FieldString;
+import org.jboss.tools.smooks.configuration.editors.uitls.JsonInputDataParser;
import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
import org.jboss.tools.smooks.model.csv12.CSV12Reader;
import org.jboss.tools.smooks.model.csv12.Csv12Factory;
+import org.jboss.tools.smooks.model.csv12.Csv12Package;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
@@ -105,6 +108,12 @@
if(recordName != null){
reader.setRecordElementName(recordName);
}
+
+ String indent = configPage.getIndent();
+ if (indent != null && indent.length() != 0) {
+ boolean indentValue = Boolean.valueOf(indent).booleanValue();
+ reader.setIndent(indentValue);
+ }
String fields = null;
List<FieldString> fieldList = configPage.getFieldsList();
@@ -120,9 +129,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(Csv12Package.Literals.CSV12_DOCUMENT_ROOT__READER, reader));
editingDomain.getCommandStack().execute(command);
}
@@ -229,6 +238,11 @@
if (skiplines != null && skiplines.length() != 0) {
pro.put(CSVDataParser.SKIPLINES, skiplines);
}
+
+ String indent = configPage.getIndent();
+ if (indent != null && indent.length() != 0) {
+ pro.setProperty(JsonInputDataParser.INDENT, indent);
+ }
}
}
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
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataWizard.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -97,7 +97,7 @@
* IStructuredDataSelectionWizard#getInputDataTypeID()
*/
public String getInputDataTypeID() {
- return SmooksModelUtils.INPUT_TYPE_EDI;
+ return SmooksModelUtils.INPUT_TYPE_EDI_1_1;
}
/*
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
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -172,7 +172,7 @@
*/
public String getInputDataTypeID() {
// TODO Auto-generated method stub
- return SmooksModelUtils.INPUT_TYPE_JSON;
+ return SmooksModelUtils.INPUT_TYPE_JSON_1_1;
}
/*
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataConfiguraitonWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataConfiguraitonWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataConfiguraitonWizardPage.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -0,0 +1,761 @@
+/*******************************************************************************
+ * 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.json12;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+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.Item;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.json12.Json12Reader;
+import org.jboss.tools.smooks.model.json12.impl.Json12ReaderImpl;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class Json12DataConfiguraitonWizardPage extends WizardPage {
+
+ private String rootName = null;
+
+ private String arrayElementName = "element";
+
+ private String keyWhitspaceReplacement = "-";
+
+ private String keyPrefixOnNumeric;
+
+ private String illegalElementNameCharReplacement;
+
+ private String nullValueReplacement = "";
+
+ private String encoding = "UTF-8";
+
+ private Text rootNameText;
+
+ private Text arrayElementNameText;
+
+ private Text keyWhitspaceReplacementText;
+
+ private Text keyPrefixOnNumericText;
+
+ private Text illegalElementNameCharReplacementText;
+
+ private Text nullValueReplacementText;
+
+ private Text encodingText;
+
+ private TableViewer keyMapViewer;
+
+ private ArrayList<KeyValueModel> keyValueList;
+
+ private Button addButton;
+
+ private Button removeButton;
+
+ private Button createJsonReaderButton;
+
+ protected boolean createJsonReader = true;
+
+ private Button newReaderConfigButton;
+
+ private Button useAvailableReaderConfigButton;
+
+ private SmooksResourceListType resourceList;
+
+ private boolean hasReader = false;
+
+ private boolean useAvailabelReader = false;
+
+ private Composite configComposite;
+
+ private Composite keyMapComposite;
+
+ private Combo indentText;
+
+ private String indent = null;
+
+ private void initValue() {
+
+ indent = null;
+
+ hasReader = false;
+ if (SmooksUIUtils.hasReaderAlready(Json12ReaderImpl.class, resourceList)
+ || SmooksUIUtils.hasReaderAlready(Json12Reader.class, resourceList)) {
+ hasReader = true;
+ }
+
+ useAvailabelReader = false;
+
+ rootName = null;
+
+ createJsonReader = true;
+
+ arrayElementName = "element";
+
+ keyWhitspaceReplacement = "-";
+
+ keyPrefixOnNumeric = null;
+
+ illegalElementNameCharReplacement = null;
+ nullValueReplacement = "";
+ encoding = "UTF-8";
+ if (keyValueList != null) {
+ keyValueList.clear();
+ } else {
+ keyValueList = new ArrayList<KeyValueModel>();
+ }
+
+ if (hasReader) {
+ useAvailabelReader = true;
+ createJsonReader = false;
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ public void createControl(Composite parent) {
+ initValue();
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ mainComposite.setLayout(layout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ mainComposite.setLayoutData(gd);
+
+ Composite radioButtonComposite = new Composite(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ radioButtonComposite.setLayoutData(gd);
+
+ GridLayout rgl = new GridLayout();
+ rgl.numColumns = 2;
+ rgl.marginHeight = 0;
+ rgl.marginWidth = 0;
+ radioButtonComposite.setLayout(rgl);
+
+ Composite spaceComposite = new Composite(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 20;
+ spaceComposite.setLayoutData(gd);
+
+ newReaderConfigButton = new Button(radioButtonComposite, SWT.RADIO);
+ newReaderConfigButton.setText("Create new JSON reader configurations");
+ newReaderConfigButton.setSelection(true);
+
+ useAvailableReaderConfigButton = new Button(radioButtonComposite, SWT.RADIO);
+ useAvailableReaderConfigButton.setText("Use available JSON reader
configurations");
+
+ configComposite = new Composite(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ configComposite.setLayoutData(gd);
+
+ GridLayout cgl = new GridLayout();
+ cgl.marginHeight = 0;
+ cgl.marginWidth = 0;
+ cgl.numColumns = 2;
+ configComposite.setLayout(cgl);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ Label rootnameLabel = new Label(configComposite, SWT.NONE);
+ rootnameLabel.setText("Root Element Name");
+ rootNameText = new Text(configComposite, SWT.BORDER);
+ rootNameText.setLayoutData(gd);
+
+ Label arrayElementNameLabel = new Label(configComposite, SWT.NONE);
+ arrayElementNameLabel.setText("Array Element Name");
+ arrayElementNameText = new Text(configComposite, SWT.BORDER);
+ arrayElementNameText.setLayoutData(gd);
+ arrayElementNameText.setText(arrayElementName);
+
+ Label keyWhitspaceReplacementLabel = new Label(configComposite, SWT.NONE);
+ keyWhitspaceReplacementLabel.setText("Space Replacement");
+ keyWhitspaceReplacementText = new Text(configComposite, SWT.BORDER);
+ keyWhitspaceReplacementText.setLayoutData(gd);
+ if (keyWhitspaceReplacement == null) {
+ keyWhitspaceReplacement = "";
+ }
+ keyWhitspaceReplacementText.setText(keyWhitspaceReplacement);
+
+ Label keyPrefixOnNumeric = new Label(configComposite, SWT.NONE);
+ keyPrefixOnNumeric.setText("Prefix On Numeric");
+ keyPrefixOnNumericText = new Text(configComposite, SWT.BORDER);
+ keyPrefixOnNumericText.setLayoutData(gd);
+
+ Label illegalElementNameCharReplacementLabel = new Label(configComposite, SWT.NONE);
+ illegalElementNameCharReplacementLabel.setText("IllegalChar Replacement");
+ illegalElementNameCharReplacementText = new Text(configComposite, SWT.BORDER);
+ illegalElementNameCharReplacementText.setLayoutData(gd);
+
+ Label nullValueReplacementlabel = new Label(configComposite, SWT.NONE);
+ nullValueReplacementlabel.setText("NullValue Replacement");
+ nullValueReplacementText = new Text(configComposite, SWT.BORDER);
+ nullValueReplacementText.setLayoutData(gd);
+ nullValueReplacementText.setText(nullValueReplacement);
+
+ Label encodingLabel = new Label(configComposite, SWT.NONE);
+ encodingLabel.setText("Encoding");
+ encodingText = new Text(configComposite, SWT.BORDER);
+ encodingText.setLayoutData(gd);
+ encodingText.setText(encoding);
+
+ Label indentLabel = new Label(configComposite, SWT.NONE);
+ indentLabel.setText("Indent");
+ indentText = new Combo(configComposite, SWT.BORDER | SWT.READ_ONLY);
+ indentText.add("");
+ indentText.add("TRUE");
+ indentText.add("FALSE");
+ indentText.setLayoutData(gd);
+
+ Label keyMapLabel = new Label(configComposite, SWT.NONE);
+ keyMapLabel.setText("Key Map:");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ keyMapLabel.setLayoutData(gd);
+
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+
+ keyMapComposite = new Composite(configComposite, SWT.NONE);
+ keyMapComposite.setLayoutData(gd);
+
+ GridLayout kgl = new GridLayout();
+ kgl.numColumns = 2;
+ keyMapComposite.setLayout(kgl);
+
+ gd = new GridData(GridData.FILL_BOTH);
+
+ keyMapViewer = new TableViewer(keyMapComposite, SWT.BORDER | SWT.MULTI);
+ keyMapViewer.getControl().setLayoutData(gd);
+ keyMapViewer.getTable().setHeaderVisible(true);
+ keyMapViewer.getTable().setLinesVisible(true);
+ keyMapViewer.setContentProvider(new KeyMapContentProvider());
+ keyMapViewer.setLabelProvider(new KeyMapLabelProvider());
+
+ CellEditor keyCellEditor = new TextCellEditor(keyMapViewer.getTable(), SWT.BORDER);
+
+ CellEditor valueCellEditor = new TextCellEditor(keyMapViewer.getTable(), SWT.BORDER);
+
+ keyMapViewer.setCellEditors(new CellEditor[] { keyCellEditor, valueCellEditor });
+
+ keyMapViewer.setColumnProperties(new String[] { "key", "value" });
+
+ keyMapViewer.setCellModifier(new ICellModifier() {
+
+ public void modify(Object element, String property, Object value) {
+ Object el = null;
+ if (element instanceof Item) {
+ el = ((Item) element).getData();
+ }
+ if (el == null)
+ return;
+ if (el instanceof KeyValueModel && value instanceof String) {
+ if (property.equals("key")) {
+ ((KeyValueModel) el).setKey(value.toString());
+ }
+ if (property.equals("value")) {
+ ((KeyValueModel) el).setValue(value.toString());
+ }
+ keyMapViewer.refresh(el);
+ }
+ }
+
+ public Object getValue(Object element, String property) {
+ // Object el = null;
+ // if(element instanceof Item){
+ // el = ((Item)element).getData();
+ // }
+ // if(el == null) return null;
+ if (element instanceof KeyValueModel) {
+ if (property.equals("key")) {
+ return ((KeyValueModel) element).getKey();
+ }
+ if (property.equals("value")) {
+ return ((KeyValueModel) element).getValue();
+ }
+ }
+
+ return null;
+ }
+
+ public boolean canModify(Object element, String property) {
+ // Object el = null;
+ // if(element instanceof Item){
+ // el = ((Item)element).getData();
+ // }
+ // if(el == null) return false;
+ if (element instanceof KeyValueModel) {
+ if (property.equals("key") || property.equals("value")) {
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+
+ TableColumn keyColumn = new TableColumn(keyMapViewer.getTable(), SWT.BORDER);
+ keyColumn.setWidth(150);
+ keyColumn.setText("Key");
+
+ TableColumn replaceColumn = new TableColumn(keyMapViewer.getTable(), SWT.BORDER);
+ replaceColumn.setWidth(150);
+ replaceColumn.setText("Replace");
+
+ keyMapViewer.setInput(keyValueList);
+
+ Composite buttonComposite = new Composite(keyMapComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ buttonComposite.setLayoutData(gd);
+
+ GridLayout bgl = new GridLayout();
+ buttonComposite.setLayout(bgl);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+
+ addButton = new Button(buttonComposite, SWT.NONE);
+ addButton.setLayoutData(gd);
+ addButton.setText("Add");
+
+ removeButton = new Button(buttonComposite, SWT.NONE);
+ removeButton.setLayoutData(gd);
+ removeButton.setText("Remove");
+
+ createJsonReaderButton = new Button(configComposite, SWT.CHECK);
+ createJsonReaderButton.setText("Create a JSON Reader");
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ createJsonReaderButton.setLayoutData(gd);
+ createJsonReaderButton.setSelection(createJsonReader);
+
+ if (hasReader) {
+ createJsonReaderButton.setEnabled(false);
+ newReaderConfigButton.setSelection(false);
+ useAvailableReaderConfigButton.setSelection(true);
+ setConfigCompositeStates(false);
+ // configComposite.setEnabled(false);
+ }
+ hookControls();
+ changePageStatus();
+ this.setControl(mainComposite);
+ }
+
+ private void setConfigCompositeStates(boolean enabled) {
+ configComposite.setEnabled(enabled);
+ Control[] controls = configComposite.getChildren();
+ for (int i = 0; i < controls.length; i++) {
+ Control c = controls[i];
+ if (c == createJsonReaderButton) {
+ if (hasReader) {
+ c.setEnabled(false);
+ continue;
+ }
+ }
+ if (c == keyMapComposite) {
+ Control[] cs = ((Composite) c).getChildren();
+ for (int j = 0; j < cs.length; j++) {
+ Control cc = cs[j];
+ cc.setEnabled(enabled);
+ }
+ }
+ c.setEnabled(enabled);
+ }
+ }
+
+ private void hookControls() {
+
+ newReaderConfigButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if (newReaderConfigButton.getSelection()) {
+ useAvailabelReader = false;
+ changePageStatus();
+ setConfigCompositeStates(true);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ useAvailableReaderConfigButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if (useAvailableReaderConfigButton.getSelection()) {
+ useAvailabelReader = true;
+ changePageStatus();
+ setConfigCompositeStates(false);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ indentText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ indent = indentText.getText();
+ changePageStatus();
+ }
+ });
+
+ addButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ keyValueList.add(new KeyValueModel("key", "value"));
+ keyMapViewer.refresh();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ removeButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection selection = (IStructuredSelection) keyMapViewer.getSelection();
+ List<?> selections = selection.toList();
+ for (Iterator<?> iterator = selections.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ keyValueList.remove(object);
+ }
+ keyMapViewer.refresh();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ createJsonReaderButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ createJsonReader = createJsonReaderButton.getSelection();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ encodingText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ encoding = encodingText.getText();
+ changePageStatus();
+ }
+ });
+
+ nullValueReplacementText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ nullValueReplacement = nullValueReplacementText.getText();
+ changePageStatus();
+ }
+ });
+
+ illegalElementNameCharReplacementText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ illegalElementNameCharReplacement = illegalElementNameCharReplacementText.getText();
+ changePageStatus();
+ }
+ });
+
+ keyPrefixOnNumericText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ keyPrefixOnNumeric = keyPrefixOnNumericText.getText();
+ changePageStatus();
+ }
+ });
+
+ keyWhitspaceReplacementText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ keyWhitspaceReplacement = keyWhitspaceReplacementText.getText();
+ changePageStatus();
+ }
+ });
+
+ arrayElementNameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ arrayElementName = arrayElementNameText.getText();
+ changePageStatus();
+ }
+ });
+
+ rootNameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ rootName = rootNameText.getText();
+ changePageStatus();
+ }
+ });
+ }
+
+ private void changePageStatus() {
+ String error = null;
+ if (useAvailabelReader) {
+ setErrorMessage(null);
+ setPageComplete(true);
+ return;
+ }
+ rootName = rootNameText.getText();
+ if (rootName == null || rootName.length() == 0) {
+ error = "Root Name can't be null";
+ }
+
+ arrayElementName = arrayElementNameText.getText();
+ if (arrayElementName == null || arrayElementName.length() == 0) {
+ error = "Array Element Name can't be null";
+ }
+
+ // if (keyWhitspaceReplacement == null
+ // || keyWhitspaceReplacement.length() == 0) {
+ // error = "Space replacement string can't be null";
+ // }
+
+ encoding = encodingText.getText();
+ if (encoding == null || encoding.length() == 0) {
+ error = "Encoding can't be null";
+ }
+
+ setErrorMessage(error);
+ setPageComplete(error == null);
+ }
+
+ public Json12DataConfiguraitonWizardPage(String pageName, String title, ImageDescriptor
titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ public Json12DataConfiguraitonWizardPage(String pageName) {
+ super(pageName);
+ this.setTitle("JSON Reader configurations (version 1.2)");
+ this.setDescription("Set the configurations for parsing JSON file.");
+ }
+
+ public String getRootName() {
+ return rootName;
+ }
+
+ public void setRootName(String rootName) {
+ this.rootName = rootName;
+ }
+
+ public String getArrayElementName() {
+ return arrayElementName;
+ }
+
+ public void setArrayElementName(String arrayElementName) {
+ this.arrayElementName = arrayElementName;
+ }
+
+ public String getKeyWhitspaceReplacement() {
+ return keyWhitspaceReplacement;
+ }
+
+ public void setKeyWhitspaceReplacement(String keyWhitspaceReplacement) {
+ this.keyWhitspaceReplacement = keyWhitspaceReplacement;
+ }
+
+ public String getKeyPrefixOnNumeric() {
+ return keyPrefixOnNumeric;
+ }
+
+ public void setKeyPrefixOnNumeric(String keyPrefixOnNumeric) {
+ this.keyPrefixOnNumeric = keyPrefixOnNumeric;
+ }
+
+ public String getIllegalElementNameCharReplacement() {
+ return illegalElementNameCharReplacement;
+ }
+
+ public void setIllegalElementNameCharReplacement(String
illegalElementNameCharReplacement) {
+ this.illegalElementNameCharReplacement = illegalElementNameCharReplacement;
+ }
+
+ public String getNullValueReplacement() {
+ return nullValueReplacement;
+ }
+
+ public void setNullValueReplacement(String nullValueReplacement) {
+ this.nullValueReplacement = nullValueReplacement;
+ }
+
+ // public Map<String, String> getKeyMap() {
+ // return keyMap;
+ // }
+ //
+ // public void setKeyMap(Map<String, String> keyMap) {
+ // this.keyMap = keyMap;
+ // }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public boolean isUseAvailabelReader() {
+ return useAvailabelReader;
+ }
+
+ public void setUseAvailabelReader(boolean useAvailabelReader) {
+ this.useAvailabelReader = useAvailabelReader;
+ }
+
+
+
+ public String getIndent() {
+ return indent;
+ }
+
+ public void setIndent(String indent) {
+ this.indent = indent;
+ }
+
+ public SmooksResourceListType getSmooksResourceList() {
+ return resourceList;
+ }
+
+ public void setSmooksResourceList(SmooksResourceListType resourceList) {
+ this.resourceList = resourceList;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ public ArrayList<KeyValueModel> getKeyValueList() {
+ return keyValueList;
+ }
+
+ public void setKeyValueList(ArrayList<KeyValueModel> keyValueList) {
+ this.keyValueList = keyValueList;
+ }
+
+ public boolean isCreateJsonReader() {
+ return createJsonReader;
+ }
+
+ public void setCreateJsonReader(boolean createJsonReader) {
+ this.createJsonReader = createJsonReader;
+ }
+
+ private class KeyMapLabelProvider extends LabelProvider implements ITableLabelProvider
{
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof KeyValueModel) {
+ switch (columnIndex) {
+ case 0:
+ return ((KeyValueModel) element).getKey();
+ case 1:
+ return ((KeyValueModel) element).getValue();
+ }
+ }
+ return getText(element);
+ }
+
+ }
+
+ private class KeyMapContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List<?>) {
+ return ((List<?>) inputElement).toArray();
+ }
+ // TODO Auto-generated method stub
+ return new Object[] {};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ public class KeyValueModel {
+ private String key;
+ private String value;
+
+ public KeyValueModel(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataConfiguraitonWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataPathWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataPathWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataPathWizardPage.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -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.json12;
+
+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 Json12DataPathWizardPage extends AbstractFileSelectionWizardPage {
+
+ public Json12DataPathWizardPage(String pageName, boolean multiSelect, Object[]
initSelections,
+ List<ViewerFilter> filters) {
+ super(pageName, multiSelect, initSelections, filters);
+ }
+
+ public Json12DataPathWizardPage(String pageName, String[] fileExtensionNames) {
+ super(pageName, fileExtensionNames);
+ this.setTitle("JSON file selection");
+ this.setDescription("Select a JSON 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/json12/Json12DataPathWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataWizard.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * 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.json12;
+
+import java.util.Iterator;
+import java.util.List;
+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.json12.Json12DataConfiguraitonWizardPage.KeyValueModel;
+import org.jboss.tools.smooks.configuration.editors.uitls.JsonInputDataParser;
+import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+import org.jboss.tools.smooks.model.json12.Json12Factory;
+import org.jboss.tools.smooks.model.json12.Json12Package;
+import org.jboss.tools.smooks.model.json12.Json12Reader;
+import org.jboss.tools.smooks.model.json12.Key;
+import org.jboss.tools.smooks.model.json12.KeyMap;
+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 (dpeng(a)redhat.com)
+ *
+ */
+public class Json12DataWizard extends Wizard implements IStructuredDataSelectionWizard,
INewWizard {
+
+ private Json12DataPathWizardPage pathPage = null;
+
+ private Json12DataConfiguraitonWizardPage configPage = null;
+
+ private SmooksResourceListType resourceList;
+
+ private EditingDomain editingDomain;
+
+ public Json12DataWizard() {
+ super();
+ this.setWindowTitle("JSON Input Data Wizard (version 1.2)");
+ }
+
+ public boolean canFinish() {
+ if (configPage != null && pathPage != null) {
+ if (configPage.isPageComplete() && pathPage.isPageComplete())
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ super.addPages();
+ if (pathPage == null) {
+ pathPage = new Json12DataPathWizardPage("Json Input Data Selection ", new
String[] {});
+
+ }
+ if (configPage == null) {
+ configPage = new Json12DataConfiguraitonWizardPage("Json data configuration
page");
+ configPage.setSmooksResourceList(resourceList);
+ }
+ this.addPage(pathPage);
+ this.addPage(configPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ if (editingDomain == null || resourceList == null) {
+ return true;
+ }
+ if (configPage != null && configPage.isCreateJsonReader()) {
+ List<KeyValueModel> keyMapList = configPage.getKeyValueList();
+
+ Json12Reader reader = Json12Factory.eINSTANCE.createJson12Reader();
+ if (keyMapList != null && !keyMapList.isEmpty()) {
+ KeyMap map = Json12Factory.eINSTANCE.createKeyMap();
+ for (Iterator<?> iterator = keyMapList.iterator(); iterator.hasNext();) {
+ KeyValueModel keyValueModel = (KeyValueModel) iterator.next();
+ String key = keyValueModel.getKey();
+ String value = keyValueModel.getValue();
+ Key k = Json12Factory.eINSTANCE.createKey();
+ k.setFrom(key);
+ k.setTo(value);
+ map.getKey().add(k);
+ }
+ reader.setKeyMap(map);
+ }
+
+ String aen = configPage.getArrayElementName();
+ if (aen != null && aen.length() != 0) {
+ reader.setArrayElementName(aen);
+ }
+
+ String rn = configPage.getRootName();
+ if (rn != null && rn.length() != 0) {
+ reader.setRootName(rn);
+ }
+
+ String encoding = configPage.getEncoding();
+ if (encoding != null && encoding.length() != 0) {
+ reader.setEncoding(encoding);
+ }
+
+ String sr = configPage.getKeyWhitspaceReplacement();
+ if (sr != null && sr.length() != 0) {
+ reader.setKeyWhitspaceReplacement(sr);
+ }
+
+ String pon = configPage.getKeyPrefixOnNumeric();
+ if (pon != null && pon.length() != 0) {
+ reader.setKeyPrefixOnNumeric(pon);
+ }
+
+ String nvr = configPage.getNullValueReplacement();
+ if (nvr != null && nvr.length() != 0) {
+ reader.setNullValueReplacement(nvr);
+ }
+
+ String ier = configPage.getIllegalElementNameCharReplacement();
+ if (ier != null && ier.length() != 0) {
+ reader.setIllegalElementNameCharReplacement(ier);
+ }
+ String indent = configPage.getIndent();
+ if (indent != null && indent.length() != 0) {
+ boolean indentValue = Boolean.valueOf(indent).booleanValue();
+ reader.setIndent(indentValue);
+ }
+
+ Command command = AddCommand.create(editingDomain, resourceList,
+ SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil
+ .createEntry(Json12Package.Literals.JSON12_DOCUMENT_ROOT__READER, reader));
+ editingDomain.getCommandStack().execute(command);
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getInputDataTypeID()
+ */
+ public String getInputDataTypeID() {
+ // TODO Auto-generated method stub
+ return SmooksModelUtils.INPUT_TYPE_JSON_1_2;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getProperties()
+ */
+ public Properties getProperties() {
+ Properties properties = new Properties();
+ fillProperties(properties);
+ return properties;
+ }
+
+ private void fillProperties(Properties p) {
+ if (configPage != null) {
+
+ boolean createJsonReader = configPage.isCreateJsonReader();
+ boolean useJsonReader = configPage.isUseAvailabelReader();
+ if (createJsonReader || useJsonReader) {
+ p.setProperty(JsonInputDataParser.LINK_JSON_READER, "true");
+ return;
+ }
+
+ List<KeyValueModel> keyMapList = configPage.getKeyValueList();
+ for (Iterator<?> iterator = keyMapList.iterator(); iterator.hasNext();) {
+ KeyValueModel keyValueModel = (KeyValueModel) iterator.next();
+ String key = keyValueModel.getKey();
+ String value = keyValueModel.getValue();
+ p.setProperty(JsonInputDataParser.KEY + key, value);
+ }
+
+ String aen = configPage.getArrayElementName();
+ if (aen != null && aen.length() != 0) {
+ p.setProperty(JsonInputDataParser.ARRAY_ELEMENT_NAME, aen);
+ }
+
+ String rn = configPage.getRootName();
+ if (rn != null && rn.length() != 0) {
+ p.setProperty(JsonInputDataParser.ROOT_NAME, rn);
+ }
+
+ String encoding = configPage.getEncoding();
+ if (encoding != null && encoding.length() != 0) {
+ p.setProperty(JsonInputDataParser.ENCODING2, encoding);
+ }
+
+ String sr = configPage.getKeyWhitspaceReplacement();
+ if (sr != null && sr.length() != 0) {
+ p.setProperty(JsonInputDataParser.SPACE_REPLACE, sr);
+ }
+
+ String pon = configPage.getKeyPrefixOnNumeric();
+ if (pon != null && pon.length() != 0) {
+ p.setProperty(JsonInputDataParser.PREFIX_ON_NUMERIC, pon);
+ }
+
+ String nvr = configPage.getNullValueReplacement();
+ if (nvr != null && nvr.length() != 0) {
+ p.setProperty(JsonInputDataParser.NULL_REPLACE, nvr);
+ }
+
+ String ier = configPage.getIllegalElementNameCharReplacement();
+ if (ier != null && ier.length() != 0) {
+ p.setProperty(JsonInputDataParser.ILLEGAL_REPLACE, ier);
+ }
+
+ String indent = configPage.getIndent();
+ if (indent != null && indent.length() != 0) {
+ p.setProperty(JsonInputDataParser.INDENT, indent);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getReturnData()
+ */
+ public Object getReturnData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getStructuredDataSourcePath()
+ */
+ public String getStructuredDataSourcePath() {
+ if (pathPage != null) {
+ return pathPage.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 (configPage != null) {
+ configPage.setSmooksResourceList(resourceList);
+ }
+ }
+
+ public void complate(SmooksMultiFormEditor formEditor) {
+
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json12/Json12DataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -7,8 +7,8 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
-import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
+import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -18,7 +18,6 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
import org.dom4j.DocumentException;
@@ -30,15 +29,15 @@
import org.jboss.tools.smooks.model.json.JsonReader;
import org.jboss.tools.smooks.model.json.Key;
import org.jboss.tools.smooks.model.json.KeyMap;
+import org.jboss.tools.smooks.model.json12.Json12Package;
+import org.jboss.tools.smooks.model.json12.Json12Reader;
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.Parameter;
-import org.milyn.cdr.SmooksResourceConfiguration;
-import org.milyn.json.JSONReader;
-import org.milyn.xml.XmlUtil;
-import org.w3c.dom.Document;
+import org.milyn.json.JSONReaderConfigurator;
+import org.milyn.payload.StringResult;
import org.w3c.dom.Element;
/**
@@ -54,10 +53,11 @@
public static final String SPACE_REPLACE = "spaceReplace";
public static final String PREFIX_ON_NUMERIC = "prefixOnNumeric";
public static final String ILLEGAL_REPLACE = "illegalReplace";
+ public static final String INDENT = "indent";
public static final String ARRAY_ELEMENT_NAME = "arrayElementName";
public static final String ROOT_NAME = "rootName";
- public IXMLStructuredObject parseJsonFile(InputStream inputStream, JsonReader reader)
+ public IXMLStructuredObject parseJsonFile(InputStream inputStream, Object readerObj)
throws ParserConfigurationException, DocumentException {
String rootName = null;
String arrayElementName = null;
@@ -66,26 +66,55 @@
String illegalElementNameCharReplacement = null;
String nullValueReplacement = null;
String encoding = null;
+ String indent = null;
Map<String, String> keyMap = new HashMap<String, String>();
- if (reader == null)
+ if (readerObj == null)
return null;
- rootName = reader.getRootName();
- arrayElementName = reader.getArrayElementName();
- keyPrefixOnNumeric = reader.getKeyPrefixOnNumeric();
- keyWhitspaceReplacement = reader.getKeyWhitspaceReplacement();
- illegalElementNameCharReplacement = reader.getIllegalElementNameCharReplacement();
- nullValueReplacement = reader.getNullValueReplacement();
- encoding = reader.getEncoding();
- KeyMap km = reader.getKeyMap();
- if (km != null) {
- List<Key> keyList = km.getKey();
- for (Iterator<?> iterator = keyList.iterator(); iterator.hasNext();) {
- Key key = (Key) iterator.next();
- keyMap.put(key.getFrom(), key.getTo());
+ if (readerObj instanceof JsonReader) {
+ JsonReader reader = (JsonReader) readerObj;
+ rootName = reader.getRootName();
+ arrayElementName = reader.getArrayElementName();
+ keyPrefixOnNumeric = reader.getKeyPrefixOnNumeric();
+ keyWhitspaceReplacement = reader.getKeyWhitspaceReplacement();
+ illegalElementNameCharReplacement = reader.getIllegalElementNameCharReplacement();
+ nullValueReplacement = reader.getNullValueReplacement();
+ encoding = reader.getEncoding();
+ KeyMap km = reader.getKeyMap();
+ if (km != null) {
+ List<Key> keyList = km.getKey();
+ for (Iterator<?> iterator = keyList.iterator(); iterator.hasNext();) {
+ Key key = (Key) iterator.next();
+ keyMap.put(key.getFrom(), key.getTo());
+ }
}
}
+
+ if (readerObj instanceof Json12Reader) {
+ Json12Reader reader = (Json12Reader) readerObj;
+ rootName = reader.getRootName();
+ arrayElementName = reader.getArrayElementName();
+ keyPrefixOnNumeric = reader.getKeyPrefixOnNumeric();
+ keyWhitspaceReplacement = reader.getKeyWhitspaceReplacement();
+ illegalElementNameCharReplacement = reader.getIllegalElementNameCharReplacement();
+ nullValueReplacement = reader.getNullValueReplacement();
+ encoding = reader.getEncoding();
+ boolean isSet = reader.eIsSet(Json12Package.Literals.JSON12_READER__INDENT);
+ if (isSet) {
+ indent = String.valueOf(reader.isIndent());
+ }
+ org.jboss.tools.smooks.model.json12.KeyMap km = reader.getKeyMap();
+ if (km != null) {
+ List<?> keyList = km.getKey();
+ for (Iterator<?> iterator = keyList.iterator(); iterator.hasNext();) {
+ org.jboss.tools.smooks.model.json12.Key key =
(org.jboss.tools.smooks.model.json12.Key) iterator
+ .next();
+ keyMap.put(key.getFrom(), key.getTo());
+ }
+ }
+ }
+
return this.parseJsonFile(inputStream, rootName, arrayElementName,
keyWhitspaceReplacement, keyPrefixOnNumeric,
- illegalElementNameCharReplacement, nullValueReplacement, keyMap, encoding);
+ illegalElementNameCharReplacement, nullValueReplacement, keyMap, indent, encoding);
}
public IXMLStructuredObject parseJsonFile(InputStream stream, InputType inputType,
@@ -99,6 +128,10 @@
String illegalElementNameCharReplacement = null;
String nullValueReplacement = null;
String encoding = null;
+ String indent = null;
+
+ String type = inputType.getType();
+
Map<String, String> keyMap = new HashMap<String, String>();
for (Iterator<?> iterator = paramList.iterator(); iterator.hasNext();) {
@@ -110,12 +143,22 @@
int index = -1;
for (Iterator<?> iterator2 = readers.iterator(); iterator2.hasNext();) {
AbstractReader abstractReader = (AbstractReader) iterator2.next();
- if (abstractReader instanceof JsonReader) {
- count++;
- if (index == -1) {
- index = readers.indexOf(abstractReader);
+ if (SmooksModelUtils.INPUT_TYPE_JSON_1_1.equals(type)) {
+ if (abstractReader instanceof JsonReader) {
+ count++;
+ if (index == -1) {
+ index = readers.indexOf(abstractReader);
+ }
}
}
+ if (SmooksModelUtils.INPUT_TYPE_JSON_1_2.equals(type)) {
+ if (abstractReader instanceof Json12Reader) {
+ count++;
+ if (index == -1) {
+ index = readers.indexOf(abstractReader);
+ }
+ }
+ }
}
if (count > 1) {
@@ -123,7 +166,7 @@
// RuntimeException("The smooks config file should have only one JSON
reader");
}
if (index != -1) {
- return parseJsonFile(stream, (JsonReader) readers.get(index));
+ return parseJsonFile(stream, readers.get(index));
}
}
@@ -154,10 +197,14 @@
if (paramType.getName().equals(NULL_REPLACE)) {
nullValueReplacement = paramType.getValue();
}
+
+ if (paramType.getName().equals(INDENT)) {
+ indent = paramType.getValue();
+ }
}
return this.parseJsonFile(stream, rootName, arrayElementName, keyWhitspaceReplacement,
keyPrefixOnNumeric,
- illegalElementNameCharReplacement, nullValueReplacement, keyMap, encoding);
+ illegalElementNameCharReplacement, nullValueReplacement, keyMap, indent, encoding);
}
public IXMLStructuredObject parseJsonFile(String filePath, InputType inputType,
SmooksResourceListType resourceList)
@@ -168,62 +215,64 @@
public IXMLStructuredObject parseJsonFile(String filePath, String rootName, String
arrayElementName,
String keyWhitspaceReplacement, String keyPrefixOnNumeric, String
illegalElementNameCharReplacement,
- String nullValueReplacement, Map<String, String> keyMap, String encoding) throws
FileNotFoundException,
- ParserConfigurationException, DocumentException, InvocationTargetException {
+ String nullValueReplacement, Map<String, String> keyMap, String indent, String
encoding)
+ throws FileNotFoundException, ParserConfigurationException, DocumentException,
InvocationTargetException {
return this.parseJsonFile(new FileInputStream(SmooksUIUtils.parseFilePath(filePath)),
rootName,
arrayElementName, keyWhitspaceReplacement, keyPrefixOnNumeric,
illegalElementNameCharReplacement,
- nullValueReplacement, keyMap, encoding);
+ nullValueReplacement, keyMap, indent, encoding);
}
public IXMLStructuredObject parseJsonFile(InputStream inputStream, String rootName,
String arrayElementName,
String keyWhitspaceReplacement, String keyPrefixOnNumeric, String
illegalElementNameCharReplacement,
- String nullValueReplacement, Map<String, String> keyMap, String encoding)
+ String nullValueReplacement, Map<String, String> keyMap, String indent, String
encoding)
throws ParserConfigurationException, DocumentException {
Smooks smooks = new Smooks();
- SmooksResourceConfiguration readerConfig = new
SmooksResourceConfiguration("org.xml.sax.driver",
- JSONReader.class.getName());
-
- readerConfig.setParameter(ROOT_NAME, rootName);
- readerConfig.setParameter(ARRAY_ELEMENT_NAME, arrayElementName);
+ JSONReaderConfigurator readerConfig = new JSONReaderConfigurator();
+ if (arrayElementName != null) {
+ readerConfig.setArrayElementName(arrayElementName);
+ }
+ if (rootName != null) {
+ readerConfig.setRootName(rootName);
+ }
if (keyWhitspaceReplacement != null) {
- readerConfig.setParameter("keyWhitspaceReplacement",
keyWhitspaceReplacement);
+ readerConfig.setKeyWhitspaceReplacement(keyWhitspaceReplacement);
}
if (keyPrefixOnNumeric != null) {
- readerConfig.setParameter("keyPrefixOnNumeric", keyPrefixOnNumeric);
+ readerConfig.setKeyPrefixOnNumeric(keyPrefixOnNumeric);
}
if (illegalElementNameCharReplacement != null) {
- readerConfig.setParameter("illegalElementNameCharReplacement",
illegalElementNameCharReplacement);
+ readerConfig.setIllegalElementNameCharReplacement(illegalElementNameCharReplacement);
}
if (nullValueReplacement != null) {
- readerConfig.setParameter("nullValueReplacement", nullValueReplacement);
+ readerConfig.setNullValueReplacement(nullValueReplacement);
}
if (keyMap != null) {
- readerConfig.setParameter(keyMapToParameter(keyMap));
+ readerConfig.setKeyMap(keyMap);
}
- readerConfig.setParameter(ENCODING2, encoding);
+ readerConfig.setEncoding(Charset.forName(encoding));
- SmooksUtil.registerResource(readerConfig, smooks);
+ if (indent != null) {
+ // readerConfig.set
+ }
+ // readerConfig.setParameter(ENCODING2, encoding);
+
+ smooks.setReaderConfig(readerConfig);
+
// Use a DOM result to capture the message model for the supplied CSV
// message...
- DOMResult domResult = new DOMResult();
+ StringResult result = new StringResult();
// Filter the message through Smooks and capture the result as a DOM in
// the domResult instance...
- smooks.filter(new StreamSource(inputStream), domResult);
+ smooks.filterSource(new StreamSource(inputStream), result);
- // Get the Document object from the domResult. This is the message
- // model!!!...
- Document model = (Document) domResult.getNode();
- StringWriter modelWriter = new StringWriter();
- 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 {
@@ -231,10 +280,6 @@
byteinputStream.close();
byteinputStream = null;
}
- if (modelWriter != null) {
- modelWriter.close();
- modelWriter = null;
- }
if (smooks != null) {
smooks.close();
smooks = null;
@@ -243,10 +288,10 @@
inputStream.close();
inputStream = null;
}
- model = null;
+ result = null;
} catch (Throwable t) {
// ignore
-// t.printStackTrace();
+ // t.printStackTrace();
}
return tagList;
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
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -24,6 +24,7 @@
import
org.jboss.tools.smooks.configuration.editors.javabean.JavabeanStrucutredDataWizard;
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanlabelProvider;
import org.jboss.tools.smooks.configuration.editors.json.JsonDataWizard;
+import org.jboss.tools.smooks.configuration.editors.json12.Json12DataWizard;
import
org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataContentProvider;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataLabelProvider;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataWizard;
@@ -145,7 +146,7 @@
String name = "Json 1.1";
String description = "Select Json data file as the input data.";
String iconPath = null;
- String typeID = SmooksModelUtils.INPUT_TYPE_JSON;
+ String typeID = SmooksModelUtils.INPUT_TYPE_JSON_1_1;
jsonViewerInitor.setName(name);
jsonViewerInitor.setDescription(description);
@@ -156,7 +157,25 @@
jsonViewerInitor.setStructuredDataLoadWizard(new JsonDataWizard());
// jsonViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
map.put(typeID, jsonViewerInitor);
+
+ // for json 1.2
+ BaseViewerInitor json12ViewerInitor = new BaseViewerInitor();
+ name = "Json 1.2";
+ description = "Select Json data file as the input data.(version 1.2)";
+ iconPath = null;
+ typeID = SmooksModelUtils.INPUT_TYPE_JSON_1_2;
+ json12ViewerInitor.setName(name);
+ json12ViewerInitor.setDescription(description);
+ json12ViewerInitor.setWizardIconPath(iconPath);
+ json12ViewerInitor.setTypeID(typeID);
+ json12ViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+ json12ViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+ json12ViewerInitor.setStructuredDataLoadWizard(new Json12DataWizard());
+ json12ViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
+ map.put(typeID, json12ViewerInitor);
+
+
// for java
BaseViewerInitor javabeanViewerInitor = new BaseViewerInitor();
name = "Java";
@@ -247,7 +266,7 @@
name = "EDI 1.1";
description = "Select EDI data file as the input data.";
iconPath = null;
- typeID = SmooksModelUtils.INPUT_TYPE_EDI;
+ typeID = SmooksModelUtils.INPUT_TYPE_EDI_1_1;
ediViewerInitor.setName(name);
ediViewerInitor.setDescription(description);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java 2009-08-18
07:03:12 UTC (rev 17118)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java 2009-08-18
08:26:17 UTC (rev 17119)
@@ -434,7 +434,7 @@
List<InputType> inputList = ext.getInput();
for (Iterator<?> iterator = inputList.iterator(); iterator.hasNext();) {
InputType inputType = (InputType) iterator.next();
- if (SmooksModelUtils.INPUT_TYPE_EDI.equals(inputType.getType())) {
+ if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(inputType.getType())) {
List<ParamType> paramList = inputType.getParam();
for (Iterator<?> iterator2 = paramList.iterator(); iterator2.hasNext();) {
ParamType paramType = (ParamType) iterator2.next();
@@ -454,7 +454,7 @@
List<InputType> inputList = ext.getInput();
for (Iterator<?> iterator = inputList.iterator(); iterator.hasNext();) {
InputType inputType = (InputType) iterator.next();
- if (SmooksModelUtils.INPUT_TYPE_EDI.equals(inputType.getType())) {
+ if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(inputType.getType())) {
List<ParamType> paramList = inputType.getParam();
for (Iterator<?> iterator2 = paramList.iterator(); iterator2.hasNext();) {
ParamType paramType = (ParamType) iterator2.next();
@@ -758,7 +758,7 @@
List<InputType> list = ext.getInput();
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
InputType inputType = (InputType) iterator.next();
- if (SmooksModelUtils.INPUT_TYPE_EDI.equals(inputType.getType())) {
+ if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(inputType.getType())) {
inputType1[0] = inputType;
break;
}
@@ -774,7 +774,7 @@
* @see java.lang.Runnable#run()
*/
public void run() {
- String type = SmooksModelUtils.INPUT_TYPE_EDI;
+ String type = SmooksModelUtils.INPUT_TYPE_EDI_1_1;
SmooksGraphicsExtType extType = modelProvider.getSmooksGraphicsExt();
InputType input = inputType1[0];
if (input == null) {
@@ -1301,7 +1301,7 @@
List<InputType> list = ext.getInput();
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
InputType inputType = (InputType) iterator.next();
- if (SmooksModelUtils.INPUT_TYPE_EDI.equals(inputType.getType())) {
+ if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(inputType.getType())) {
inputType1[0] = inputType;
break;
}
@@ -1315,7 +1315,7 @@
*/
public void run() {
SmooksUIUtils.recordInputDataInfomation(inputType1[0],
modelProvider.getSmooksGraphicsExt(),
- SmooksModelUtils.INPUT_TYPE_EDI, ediFilePath, null);
+ SmooksModelUtils.INPUT_TYPE_EDI_1_1, ediFilePath, null);
}
});