Author: DartPeng
Date: 2009-07-15 03:23:53 -0400 (Wed, 15 Jul 2009)
New Revision: 16572
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/ComponentUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/DelimitersUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java
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/editparts/EDIMappingNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
Log:
JBIDE-4592
adjust the layout of the mapping editor
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/ComponentUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/ComponentUICreator.java 2009-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/ComponentUICreator.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -46,4 +46,17 @@
formEditor,part);
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.PropertyUICreator#ignoreProperty(org.eclipse.emf.ecore.EAttribute)
+ */
+ @Override
+ public boolean ignoreProperty(EAttribute feature) {
+ if(feature == MEdiPackage.Literals.MAPPING_NODE__XMLTAG){
+ return true;
+ }
+ return super.ignoreProperty(feature);
+ }
+
+
+
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/DelimitersUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/DelimitersUICreator.java 2009-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/DelimitersUICreator.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -17,6 +17,8 @@
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.IModelProcsser;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.model.medi.MEdiPackage;
@@ -35,20 +37,133 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public AttributeFieldEditPart createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
- ISmooksModelProvider formEditor, IEditorPart part) {
-
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ ISmooksModelProvider formEditor, IEditorPart part) {
+
if (feature == MEdiPackage.eINSTANCE.getDelimiters_Component()) {
+ return SmooksUIUtils.createChoiceFieldEditor(parent, toolkit, propertyDescriptor,
model,
+ new String[] { ENTER_CHAR_STRING }, new IModelProcsser() {
+
+ public Object unwrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals("\n")) {
+ return ENTER_CHAR_STRING;
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ public Object wrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals(ENTER_CHAR_STRING)) {
+ return "\n";
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ }, false);
}
if (feature == MEdiPackage.eINSTANCE.getDelimiters_Field()) {
+ return SmooksUIUtils.createChoiceFieldEditor(parent, toolkit, propertyDescriptor,
model,
+ new String[] { ENTER_CHAR_STRING }, new IModelProcsser() {
+
+ public Object unwrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals("\n")) {
+ return ENTER_CHAR_STRING;
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ public Object wrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals(ENTER_CHAR_STRING)) {
+ return "\n";
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ }, false);
}
if (feature == MEdiPackage.eINSTANCE.getDelimiters_Segment()) {
+ return SmooksUIUtils.createChoiceFieldEditor(parent, toolkit, propertyDescriptor,
model,
+ new String[] { ENTER_CHAR_STRING }, new IModelProcsser() {
+
+ public Object unwrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals("\n")) {
+ return ENTER_CHAR_STRING;
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ public Object wrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals(ENTER_CHAR_STRING)) {
+ return "\n";
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ }, false);
}
if (feature == MEdiPackage.eINSTANCE.getDelimiters_SubComponent()) {
+ return SmooksUIUtils.createChoiceFieldEditor(parent, toolkit, propertyDescriptor,
model,
+ new String[] { ENTER_CHAR_STRING }, new IModelProcsser() {
+
+ public Object unwrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals("\n")) {
+ return ENTER_CHAR_STRING;
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ public Object wrapValue(Object model) {
+ if (model == null)
+ return null;
+ if (model instanceof String) {
+ if (((String) model).equals(ENTER_CHAR_STRING)) {
+ return "\n";
+ }
+ return model.toString();
+ }
+ return null;
+ }
+
+ }, false);
}
- return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
- formEditor,part);
+ return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor, part);
}
+
+ public static final String ENTER_CHAR_STRING = "<Enter>";
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java 2009-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -59,9 +59,9 @@
*/
@Override
public boolean ignoreProperty(EAttribute feature) {
- if (feature == MEdiPackage.Literals.MAPPING_NODE__XMLTAG) {
- return true;
- }
+// if (feature == MEdiPackage.Literals.MAPPING_NODE__XMLTAG) {
+// return true;
+// }
if (feature == MEdiPackage.Literals.SEGMENT__SEGCODE) {
return true;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -111,6 +111,7 @@
import org.jboss.tools.smooks.configuration.editors.FieldMarkerComposite;
import org.jboss.tools.smooks.configuration.editors.FileSelectionWizard;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.configuration.editors.IFilePathProcessor;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
import org.jboss.tools.smooks.configuration.editors.OpenFileHyperLinkListener;
import org.jboss.tools.smooks.configuration.editors.SelectorAttributes;
@@ -575,6 +576,16 @@
Object model, boolean multiText, boolean linkLabel, boolean openFile, int height,
IHyperlinkListener listener, int valueType, OpenEditorEditInnerContentsAction
openEditorAction,
boolean expandEditor) {
+ return createStringFieldEditor(label, parent, editingdomain, toolkit,
itemPropertyDescriptor, model, multiText,
+ linkLabel, openFile, new ClassPathFileProcessor(), height, listener, valueType,
openEditorAction,
+ expandEditor);
+ }
+
+ public static AttributeFieldEditPart createStringFieldEditor(String label, final
Composite parent,
+ EditingDomain editingdomain, FormToolkit toolkit, final IItemPropertyDescriptor
itemPropertyDescriptor,
+ Object model, boolean multiText, boolean linkLabel, boolean openFile,
IFilePathProcessor filePathProcessor,
+ int height, IHyperlinkListener listener, int valueType,
OpenEditorEditInnerContentsAction openEditorAction,
+ boolean expandEditor) {
AttributeFieldEditPart fieldEditPart = new AttributeFieldEditPart();
GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Section section = null;
@@ -706,6 +717,7 @@
toolkit.paintBordersFor(textContainer);
if (openFile) {
+ final IFilePathProcessor processor = filePathProcessor;
Button fileBrowseButton = toolkit.createButton(textContainer, "Browse",
SWT.NONE);
fileBrowseButton.addSelectionListener(new SelectionAdapter() {
@@ -716,7 +728,7 @@
if (resource != null) {
initSelections = new Object[] { resource };
}
- wizard.setFilePathProcessor(new ClassPathFileProcessor());
+ wizard.setFilePathProcessor(processor);
wizard.setInitSelections(initSelections);
List<ViewerFilter> filterList = new ArrayList<ViewerFilter>();
filterList.add(new CurrentProjecViewerFilter(resource));
@@ -1304,7 +1316,12 @@
if (currentSelect != -1) {
combo.select(currentSelect);
+ } else {
+
}
+ if (editValue instanceof String) {
+ combo.setText(editValue.toString());
+ }
final Object fm = model;
final ItemPropertyDescriptor fipd = (ItemPropertyDescriptor) itemPropertyDescriptor;
final IModelProcsser fp = processer;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java 2009-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -92,18 +92,18 @@
if(map == null){
map = MEdiFactory.eINSTANCE.createEdiMap();
((DocumentRoot)smooksModel).setEdimap(map);
- Description description = map.getDescription();
- if(description == null){
- description = MEdiFactory.eINSTANCE.createDescription();
- map.setDescription(description);
- }
-
- Delimiters delimiters = map.getDelimiters();
- if(delimiters == null){
- delimiters = MEdiFactory.eINSTANCE.createDelimiters();
- map.setDelimiters(delimiters);
- }
}
+ Description description = map.getDescription();
+ if(description == null){
+ description = MEdiFactory.eINSTANCE.createDescription();
+ map.setDescription(description);
+ }
+
+ Delimiters delimiters = map.getDelimiters();
+ if(delimiters == null){
+ delimiters = MEdiFactory.eINSTANCE.createDelimiters();
+ map.setDelimiters(delimiters);
+ }
}
}
}
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-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
@@ -87,7 +88,9 @@
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.AttributeFieldEditPart;
+import org.jboss.tools.smooks.configuration.editors.IFilePathProcessor;
import org.jboss.tools.smooks.configuration.editors.ModelPanelCreator;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
@@ -108,6 +111,7 @@
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
import org.jboss.tools.smooks.model.graphics.ext.FigureType;
+import org.jboss.tools.smooks.model.graphics.ext.GraphFactory;
import org.jboss.tools.smooks.model.graphics.ext.GraphType;
import org.jboss.tools.smooks.model.graphics.ext.ISmooksGraphChangeListener;
import org.jboss.tools.smooks.model.graphics.ext.InputType;
@@ -165,6 +169,8 @@
private Composite delimitersComposite;
+ private String ediFileEncoding = "UTF-8";
+
public EDIMapFormPage(FormEditor editor, String id, String title) {
super(editor, id, title);
if (editor instanceof ISmooksModelProvider) {
@@ -382,15 +388,6 @@
disposeCompositeControls(delimitersComposite, null);
- AttributeFieldEditPart pathEditPart =
SmooksUIUtils.createFileSelectionTextFieldEditor("EDI Mapping File",
- delimitersComposite, editingDomain, toolkit, null, null,
SmooksUIUtils.VALUE_TYPE_TEXT, null, null);
- final Text ediFileText = (Text) pathEditPart.getContentControl();
- String filePath = getEDIFilePath();
- if (filePath != null) {
- ediFileText.setText(filePath);
- }
- ediFileText.addModifyListener(this);
-
if (delimitersCreator != null) {
IItemPropertySource itemPropertySource = (IItemPropertySource)
editingDomain.getAdapterFactory().adapt(
delimiters, IItemPropertySource.class);
@@ -449,6 +446,26 @@
return null;
}
+ private String getEDIFileEncoding() {
+ if (modelProvider != null) {
+ SmooksGraphicsExtType ext = modelProvider.getSmooksGraphicsExt();
+ 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())) {
+ List<ParamType> paramList = inputType.getParam();
+ for (Iterator<?> iterator2 = paramList.iterator(); iterator2.hasNext();) {
+ ParamType paramType = (ParamType) iterator2.next();
+ if ("encoding".equals(paramType.getName())) {
+ return paramType.getValue();
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
private ActionRegistry getActionRegistry() {
if (actionRegistry == null)
actionRegistry = new ActionRegistry();
@@ -609,7 +626,7 @@
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = GridData.BEGINNING;
descriptionSection.setLayoutData(gd);
- descriptionSection.setText("Mapping Description");
+ descriptionSection.setText("Description");
FillLayout flayout = new FillLayout();
descriptionSection.setLayout(flayout);
@@ -631,53 +648,12 @@
descriptionCreator.createModelPanel(toolkit, descriptorComposite, modelProvider,
getEditor());
}
- Hyperlink showTransformResultLink = toolkit.createHyperlink(desciptorContainer,
"Test EDI transform", SWT.NONE);
- // showTransformResultLink.setVisible(false);
- showTransformResultLink.addHyperlinkListener(new IHyperlinkListener() {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(
- * org.eclipse.ui.forms.events.HyperlinkEvent)
- */
- public void linkActivated(HyperlinkEvent e) {
- testEDITransform();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org
- * .eclipse.ui.forms.events.HyperlinkEvent)
- */
- public void linkEntered(HyperlinkEvent e) {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org
- * .eclipse.ui.forms.events.HyperlinkEvent)
- */
- public void linkExited(HyperlinkEvent e) {
-
- }
-
- });
- gd = new GridData();
- showTransformResultLink.setLayoutData(gd);
-
Section delimiterSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR |
Section.DESCRIPTION);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = GridData.BEGINNING;
gd.verticalSpan = 2;
delimiterSection.setLayoutData(gd);
- delimiterSection.setText("EDI File Configurations");
+ delimiterSection.setText("Delimiters");
FillLayout flayout1 = new FillLayout();
delimiterSection.setLayout(flayout1);
@@ -687,8 +663,56 @@
delimitersComposite.setLayout(gl1);
delimiterSection.setClient(delimitersComposite);
- AttributeFieldEditPart pathEditPart =
SmooksUIUtils.createFileSelectionTextFieldEditor("EDI Mapping File",
- delimitersComposite, editingDomain, toolkit, null, null,
SmooksUIUtils.VALUE_TYPE_TEXT, null, null);
+ if (delimitersCreator != null) {
+ Map<Object, Object> editPartMap = delimitersCreator.createModelPanel(toolkit,
delimitersComposite,
+ modelProvider, getEditor());
+ handleDelimiterFieldEditor(editPartMap);
+ }
+
+ Section testSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR |
Section.DESCRIPTION);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.verticalAlignment = GridData.BEGINNING;
+ // gd.horizontalSpan = 2;
+ testSection.setLayoutData(gd);
+ testSection.setText("EDI File Setting");
+ FillLayout flayout2 = new FillLayout();
+ testSection.setLayout(flayout2);
+
+ Composite fileComposite = toolkit.createComposite(testSection, SWT.NONE);
+ GridLayout fgl = new GridLayout();
+ fgl.numColumns = 2;
+ fileComposite.setLayout(fgl);
+ testSection.setClient(fileComposite);
+
+ AttributeFieldEditPart pathEditPart = SmooksUIUtils.createStringFieldEditor("EDI
File", fileComposite,
+ editingDomain, toolkit, null, null, false, false, true, new IFilePathProcessor() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.
+ * IFilePathProcessor
+ * #processFileSystemPath(java.lang.String)
+ */
+ public String processFileSystemPath(String filePath) {
+ return filePath;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.
+ * IFilePathProcessor
+ * #processWorkBenchPath(org.eclipse.core.resources.IFile)
+ */
+ public String processWorkBenchPath(IFile file) {
+ String s = file.getFullPath().toPortableString();
+ s = SmooksUIUtils.WORKSPACE_PRIX + s;
+ return s;
+ }
+
+ }, 0, null, -1, null, false);
+
final Text ediFileText = (Text) pathEditPart.getContentControl();
String filePath = getEDIFilePath();
if (filePath != null) {
@@ -696,23 +720,88 @@
}
ediFileText.addModifyListener(this);
- if (delimitersCreator != null) {
- Map<Object, Object> editPartMap = delimitersCreator.createModelPanel(toolkit,
delimitersComposite,
- modelProvider, getEditor());
- handleDelimiterFieldEditor(editPartMap);
+ AttributeFieldEditPart encodingEditPart =
SmooksUIUtils.createStringFieldEditor("EDI File Encoding",
+ fileComposite, editingDomain, toolkit, null, null, false, false, false, 0, null, -1,
null);
+ final Text encodingText = (Text) encodingEditPart.getContentControl();
+ String encoding = getEDIFileEncoding();
+ if (encoding != null) {
+ encodingText.setText(encoding);
}
+ encodingText.addModifyListener(new ModifyListener() {
- // Section testSection = toolkit.createSection(form.getBody(),
- // Section.TITLE_BAR | Section.TWISTIE | Section.DESCRIPTION);
- // gd = new GridData(GridData.FILL_HORIZONTAL);
- // gd.verticalAlignment = GridData.BEGINNING;
- // // gd.horizontalSpan = 2;
- // testSection.setLayoutData(gd);
- // testSection.setText("Mapping Descriptor");
- // FillLayout flayout2 = new FillLayout();
- // testSection.setLayout(flayout2);
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.
+ * swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ ediFileEncoding = encodingText.getText();
+ ediFilePath = ediFileText.getText();
+ final InputType[] inputType1 = new InputType[1];
+ SmooksGraphicsExtType ext = modelProvider.getSmooksGraphicsExt();
+ 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())) {
+ inputType1[0] = inputType;
+ break;
+ }
+ }
- Section ediModelViewerSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR
| Section.DESCRIPTION);
+ final Properties pro = new Properties();
+ pro.setProperty("encoding", ediFileEncoding);
+ getEditorSite().getShell().getDisplay().syncExec(new Runnable() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ String type = SmooksModelUtils.INPUT_TYPE_EDI;
+ SmooksGraphicsExtType extType = modelProvider.getSmooksGraphicsExt();
+ InputType input = inputType1[0];
+ if (input == null) {
+ input = GraphFactory.eINSTANCE.createInputType();
+ }
+ input.setType(type);
+ ParamType encodingParam = null;
+ List<ParamType> paramList = input.getParam();
+ for (Iterator<?> iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType paramType = (ParamType) iterator.next();
+ if ("encoding".equals(paramType.getName())) {
+ encodingParam = paramType;
+ break;
+ }
+ }
+ if (encodingParam == null) {
+ encodingParam = GraphFactory.eINSTANCE.createParamType();
+ encodingParam.setName("encoding");
+ }
+ encodingParam.setValue(ediFileEncoding);
+
+ input.getParam().add(encodingParam);
+ try {
+ extType.eResource().save(Collections.emptyMap());
+ List<ISmooksGraphChangeListener> listeners = extType.getChangeListeners();
+ for (Iterator<?> iterator = listeners.iterator(); iterator.hasNext();) {
+ ISmooksGraphChangeListener smooksGraphChangeListener =
(ISmooksGraphChangeListener) iterator
+ .next();
+ smooksGraphChangeListener.saveComplete(extType);
+ }
+ } catch (IOException e) {
+ SmooksConfigurationActivator.getDefault().log(e);
+ }
+ }
+ });
+
+ }
+
+ });
+
+ Section ediModelViewerSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR
);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
ediModelViewerSection.setLayoutData(gd);
@@ -726,7 +815,29 @@
vgl.numColumns = 2;
viewerComposite.setLayout(vgl);
+
+ Hyperlink showTransformResultLink = toolkit.createHyperlink(viewerComposite, "Test
EDI to XML transform",
+ SWT.NONE);
+ // showTransformResultLink.setVisible(false);
+ showTransformResultLink.addHyperlinkListener(new IHyperlinkListener() {
+ public void linkActivated(HyperlinkEvent e) {
+ testEDITransform();
+ }
+
+ public void linkEntered(HyperlinkEvent e) {
+
+ }
+
+ public void linkExited(HyperlinkEvent e) {
+
+ }
+
+ });
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ showTransformResultLink.setLayoutData(gd);
+
SashForm sashForm = new SashForm(viewerComposite, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
@@ -1108,7 +1219,10 @@
File f = new File(file.getLocation().toOSString());
readerConfig.setParameter("mapping-model", f.toURI().toString());
- readerConfig.setParameter("encoding", "UTF-8");
+ if (ediFileEncoding == null || ediFileEncoding.trim().length() == 0) {
+ ediFileEncoding = "UTF-8";
+ }
+ readerConfig.setParameter("encoding", ediFileEncoding);
SmooksUtil.registerResource(readerConfig, smooks);
@@ -1121,7 +1235,8 @@
// in
// the domResult instance...
// FileInputStream stream
- smooks.filter(new StreamSource(new FileInputStream(ediFile)), domResult);
+ FileInputStream ediInputStream = new FileInputStream(ediFile);
+ smooks.filter(new StreamSource(ediInputStream), domResult);
// Get the Document object from the domResult. This is the message
// model!!!...
@@ -1134,11 +1249,13 @@
// We'll just print out the model DOM here so you can see it....
StringWriter modelWriter = new StringWriter();
XmlUtil.serialize(model, true, modelWriter);
- System.out.println(modelWriter);
+ // System.out.println(modelWriter);
EDIMappingResultDialog dialog = new EDIMappingResultDialog(getSite().getShell());
dialog.setText(modelWriter.toString());
dialog.open();
modelWriter.close();
+ ediInputStream.close();
+ model = null;
} catch (Throwable t) {
SmooksUIUtils.showErrorDialog(getEditorSite().getShell(),
SmooksUIUtils.createErrorStatus(t));
} finally {
@@ -1148,18 +1265,29 @@
public void modifyText(ModifyEvent e) {
Text ediFileText = (Text) e.getSource();
ediFilePath = ediFileText.getText();
- InputType inputType1 = null;
+ final InputType[] inputType1 = new InputType[1];
SmooksGraphicsExtType ext = modelProvider.getSmooksGraphicsExt();
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())) {
- inputType1 = inputType;
+ inputType1[0] = inputType;
break;
}
}
- SmooksUIUtils.recordInputDataInfomation(inputType1,
modelProvider.getSmooksGraphicsExt(),
- SmooksModelUtils.INPUT_TYPE_EDI, ediFilePath, null);
+ getEditorSite().getShell().getDisplay().syncExec(new Runnable() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ SmooksUIUtils.recordInputDataInfomation(inputType1[0],
modelProvider.getSmooksGraphicsExt(),
+ SmooksModelUtils.INPUT_TYPE_EDI, ediFilePath, null);
+ }
+
+ });
rebuildEDIGraph();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/EDIMappingNodeEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/EDIMappingNodeEditPart.java 2009-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/EDIMappingNodeEditPart.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -11,6 +11,8 @@
package org.jboss.tools.smooks.edimap.editparts;
import org.jboss.tools.smooks.edimap.editor.EDITreeNodeEditPart;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+import org.jboss.tools.smooks.model.medi.Segment;
/**
* @author Dart (dpeng(a)redhat.com)
@@ -36,7 +38,11 @@
*/
@Override
protected boolean isDragLink() {
- return true;
+ TreeNodeModel treeNode = (TreeNodeModel)getModel();
+ if(treeNode.getData() instanceof Segment){
+ return true;
+ }
+ return false;
}
/*
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-07-14
17:19:19 UTC (rev 16571)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-07-15
07:23:53 UTC (rev 16572)
@@ -68,6 +68,9 @@
* .eclipse.gef.Request)
*/
public DragTracker getDragTracker(Request request) {
+// if(true){
+// return super.getDragTracker(request);
+// }
if (isDragLink()) {
getViewer().select(this);
return new ConnectionDragCreationTool();