Author: DartPeng
Date: 2009-12-03 21:29:39 -0500 (Thu, 03 Dec 2009)
New Revision: 19039
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/provider/SmooksResourceListTypeItemProvider.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/SmooksReaderFormPage.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/edi/EDIDataParser.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/xml/XMLObjectAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java
Log:
JBIDE-5368
Done
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/provider/SmooksResourceListTypeItemProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/provider/SmooksResourceListTypeItemProvider.java 2009-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/provider/SmooksResourceListTypeItemProvider.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -26,16 +26,12 @@
import org.jboss.tools.smooks.model.calc.CalcFactory;
import org.jboss.tools.smooks.model.calc.CalcPackage;
import org.jboss.tools.smooks.model.common.provider.AbstractAnyTypeItemProvider;
-import org.jboss.tools.smooks.model.csv.CsvFactory;
-import org.jboss.tools.smooks.model.csv.CsvPackage;
import org.jboss.tools.smooks.model.csv12.Csv12Factory;
import org.jboss.tools.smooks.model.csv12.Csv12Package;
import org.jboss.tools.smooks.model.datasource.DatasourceFactory;
import org.jboss.tools.smooks.model.datasource.DatasourcePackage;
import org.jboss.tools.smooks.model.dbrouting.DbroutingFactory;
import org.jboss.tools.smooks.model.dbrouting.DbroutingPackage;
-import org.jboss.tools.smooks.model.edi.EdiFactory;
-import org.jboss.tools.smooks.model.edi.EdiPackage;
import org.jboss.tools.smooks.model.edi12.Edi12Factory;
import org.jboss.tools.smooks.model.edi12.Edi12Package;
import org.jboss.tools.smooks.model.esbrouting.EsbroutingFactory;
@@ -48,16 +44,12 @@
import org.jboss.tools.smooks.model.groovy.GroovyPackage;
import org.jboss.tools.smooks.model.iorouting.IoroutingFactory;
import org.jboss.tools.smooks.model.iorouting.IoroutingPackage;
-import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
-import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
import org.jboss.tools.smooks.model.jmsrouting.JmsroutingFactory;
import org.jboss.tools.smooks.model.jmsrouting.JmsroutingPackage;
import org.jboss.tools.smooks.model.jmsrouting12.Jmsrouting12Factory;
import org.jboss.tools.smooks.model.jmsrouting12.Jmsrouting12Package;
-import org.jboss.tools.smooks.model.json.JsonFactory;
-import org.jboss.tools.smooks.model.json.JsonPackage;
import org.jboss.tools.smooks.model.json12.Json12Factory;
import org.jboss.tools.smooks.model.json12.Json12Package;
import org.jboss.tools.smooks.model.persistence12.Persistence12Factory;
@@ -302,19 +294,24 @@
.createResourceConfigType())));
/***********************************************/
// for CSV
- newChildDescriptors.add(createChildParameter(
- SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil.createEntry(
- CsvPackage.Literals.CSV_DOCUMENT_ROOT__READER,
CsvFactory.eINSTANCE.createCsvReader())));
- // for EDI
- newChildDescriptors.add(createChildParameter(
- SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil.createEntry(
- EdiPackage.Literals.EDI_DOCUMENT_ROOT__READER,
EdiFactory.eINSTANCE.createEDIReader())));
+ // newChildDescriptors.add(createChildParameter(
+ // SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
+ // FeatureMapUtil.createEntry(
+ // CsvPackage.Literals.CSV_DOCUMENT_ROOT__READER,
+ // CsvFactory.eINSTANCE.createCsvReader())));
+ // // for EDI
+ // newChildDescriptors.add(createChildParameter(
+ // SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
+ // FeatureMapUtil.createEntry(
+ // EdiPackage.Literals.EDI_DOCUMENT_ROOT__READER,
+ // EdiFactory.eINSTANCE.createEDIReader())));
+ //
+ // // for JSON
+ // newChildDescriptors.add(createChildParameter(
+ // SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
+ // FeatureMapUtil.createEntry(
+ // JsonPackage.Literals.JSON_DOCUMENT_ROOT__READER,
JsonFactory.eINSTANCE.createJsonReader())));
- // for JSON
- newChildDescriptors.add(createChildParameter(
- SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
FeatureMapUtil.createEntry(
- JsonPackage.Literals.JSON_DOCUMENT_ROOT__READER,
JsonFactory.eINSTANCE.createJsonReader())));
-
// for calc
newChildDescriptors.add(createChildParameter(
SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP,
FeatureMapUtil
@@ -340,10 +337,10 @@
DatasourceFactory.eINSTANCE.createDataSourceJndi())));
// for javabean
- newChildDescriptors.add(createChildParameter(
- SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP,
FeatureMapUtil
- .createEntry(JavabeanPackage.Literals.DOCUMENT_ROOT__BINDINGS,
JavabeanFactory.eINSTANCE
- .createBindingsType())));
+// newChildDescriptors.add(createChildParameter(
+// SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP,
FeatureMapUtil
+// .createEntry(JavabeanPackage.Literals.DOCUMENT_ROOT__BINDINGS,
JavabeanFactory.eINSTANCE
+// .createBindingsType())));
// for xsl
newChildDescriptors.add(createChildParameter(
SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP,
FeatureMapUtil
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-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -75,12 +75,21 @@
private SelectorAttributes selectorAttributes = null;
private IEditorPart editorPart = null;
+ private static Throwable currentException = null;
+
private FormToolkit toolkit;
public SelectorCreationDialog(IShellProvider parentShell) {
super(parentShell);
}
+ /**
+ * @return the currentException
+ */
+ public static Throwable getCurrentException() {
+ return currentException;
+ }
+
public SelectorCreationDialog(Shell parentShell, IEditorPart editorPart) {
super(parentShell);
selectorAttributes = new SelectorAttributes();
@@ -113,7 +122,8 @@
toolkit = new FormToolkit(getShell().getDisplay());
- Hyperlink link = toolkit.createHyperlink(composite,
Messages.SelectorCreationDialog_AddInputLinkLabel, SWT.NONE);// new
+ Hyperlink link = toolkit
+ .createHyperlink(composite, Messages.SelectorCreationDialog_AddInputLinkLabel,
SWT.NONE);// new
// Hyperlink(composite,SWT.NONE);
link.setBackground(composite.getBackground());
link.addHyperlinkListener(new IHyperlinkListener() {
@@ -241,6 +251,7 @@
}
public static List<Object> generateInputData(SmooksResourceListType
smooksResourceListType) {
+ currentException = null;
List<Object> list = new ArrayList<Object>();
if (smooksResourceListType != null) {
IJavaProject project = SmooksUIUtils.getJavaProject(smooksResourceListType);
@@ -263,7 +274,7 @@
list.addAll(((TagList) tl).getChildren());
}
} catch (Throwable t) {
- t.printStackTrace();
+ currentException = t;
}
}
if (SmooksModelUtils.INPUT_TYPE_CSV.equals(type)
@@ -275,7 +286,7 @@
list.addAll(((TagList) tl).getChildren());
}
} catch (Throwable t) {
- t.printStackTrace();
+ currentException = t;
}
}
if (SmooksModelUtils.INPUT_TYPE_JSON_1_1.equals(type)
@@ -290,8 +301,7 @@
list.add(tagList);
}
} catch (Throwable tt) {
- // ignore
- // SmooksConfigurationActivator.getDefault().log(tt);
+ currentException = tt;
}
}
if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
@@ -302,7 +312,7 @@
list.add(model);
}
} catch (Throwable t) {
- // ignore
+ currentException = t;
}
}
if (SmooksModelUtils.INPUT_TYPE_XSD.equals(type)) {
@@ -323,7 +333,7 @@
list.add(new XSDObjectAnalyzer().loadElement(path, rootElementName));
}
} catch (Throwable tt) {
- // ingore
+ currentException = tt;
}
}
if (SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
@@ -343,12 +353,13 @@
}
}
} catch (Throwable e) {
- e.printStackTrace();
+ currentException = e;
}
}
}
}
} catch (Exception e) {
+ currentException = e;
// SmooksConfigurationActivator.getDefault().log(e);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2009-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.EventObject;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -23,6 +24,9 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.common.command.CommandWrapper;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EObject;
@@ -32,6 +36,7 @@
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.command.DeleteCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -43,6 +48,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
@@ -69,6 +75,8 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -112,8 +120,44 @@
* @author Dart
*
*/
-public class SmooksReaderFormPage extends FormPage implements
ISmooksModelValidateListener, ISourceSynchronizeListener {
+public class SmooksReaderFormPage extends FormPage implements
ISmooksModelValidateListener, ISourceSynchronizeListener,
+ CommandStackListener {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.common.command.CommandStackListener#commandStackChanged
+ * (java.util.EventObject)
+ */
+ public void commandStackChanged(EventObject event) {
+ final Command mostRecentCommand = ((org.eclipse.emf.common.command.CommandStack)
event.getSource())
+ .getMostRecentCommand();
+ getEditorSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (mostRecentCommand != null) {
+ Command rawCommand = mostRecentCommand;
+ while (rawCommand instanceof CommandWrapper) {
+ rawCommand = ((CommandWrapper) rawCommand).getCommand();
+ }
+ if (rawCommand instanceof CompoundCommand) {
+ List<Command> command = ((CompoundCommand) rawCommand).getCommandList();
+ for (Iterator<?> iterator = command.iterator(); iterator.hasNext();) {
+ Command command2 = (Command) iterator.next();
+ while (command2 instanceof CommandWrapper) {
+ command2 = ((CommandWrapper) command2).getCommand();
+ }
+ handleInputParamChange(command2);
+ }
+ } else {
+ handleInputParamChange(rawCommand);
+ }
+ }
+ }
+ });
+
+ }
+
private CheckboxTableViewer inputDataViewer;
private TreeViewer inputModelViewer;
private Combo readerCombo;
@@ -136,8 +180,8 @@
protected void createFormContent(IManagedForm managedForm) {
final ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
+ form.setText("");
// toolkit.decorateFormHeading(form.getForm());
- // form.setText("Input");
// // create master details UI
// createMasterDetailBlock(managedForm);
Composite leftComposite = toolkit.createComposite(form.getBody());
@@ -222,8 +266,6 @@
inputModelViewer = new TreeViewer(viewerContainer, SWT.NONE);
inputModelViewer.setContentProvider(new CompoundStructuredDataContentProvider());
inputModelViewer.setLabelProvider(new CompoundStructuredDataLabelProvider());
- List<Object> inputList = generateInputData();
- inputModelViewer.setInput(inputList);
inputModelViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
}
@@ -234,8 +276,9 @@
// event.getSelection()).getFirstElement();
}
});
- SmooksUIUtils.expandSelectorViewer(inputList, inputModelViewer);
+ refreshInputModelView();
+
}
protected List<Object> generateInputData() {
@@ -247,6 +290,84 @@
return SelectorCreationDialog.generateInputData(resourceList);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.editor.FormPage#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput input) {
+ super.init(site, input);
+ if (getEditor() != null && getEditor() instanceof ISmooksModelProvider) {
+ this.handleCommandStack(((ISmooksModelProvider)
getEditor()).getEditingDomain().getCommandStack());
+ }
+ }
+
+ protected void handleInputParamChange(Command command) {
+ Collection<?> affectedObjects = command.getAffectedObjects();
+ boolean refreshInputModel = false;
+ for (Iterator<?> iterator2 = affectedObjects.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+ if (object instanceof AbstractReader) {
+ refreshInputModel = true;
+ break;
+ }
+ if (object instanceof ParamType) {
+ if (SmooksUIUtils.isInputParamType((ParamType) object)) {
+ refreshInputModel = true;
+ break;
+ }
+ }
+ Collection<?> deletedObjs = null;
+ if (command instanceof DeleteCommand) {
+ deletedObjs = ((DeleteCommand) command).getCollection();
+ }
+ if (command instanceof RemoveCommand) {
+ deletedObjs = ((RemoveCommand) command).getCollection();
+ }
+ if (deletedObjs != null) {
+ for (Iterator<?> iterator = deletedObjs.iterator(); iterator.hasNext();) {
+ Object object2 = (Object) iterator.next();
+ if (object2 instanceof AbstractReader) {
+ refreshInputModel = true;
+ break;
+ }
+ if (object2 instanceof ParamType) {
+ if (SmooksUIUtils.isInputParamType((ParamType) object2)) {
+ refreshInputModel = true;
+ break;
+ }
+ }
+ }
+ }
+ if (refreshInputModel)
+ break;
+ }
+
+ if (refreshInputModel) {
+ refreshInputModelView();
+ }
+ }
+
+ private void handleCommandStack(CommandStack commandStack) {
+ commandStack.addCommandStackListener(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.editor.FormPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (getEditor() != null && getEditor() instanceof ISmooksModelProvider) {
+ ((ISmooksModelProvider)
getEditor()).getEditingDomain().getCommandStack().removeCommandStackListener(this);
+ }
+ super.dispose();
+ }
+
private void createReaderConfigSection(FormToolkit toolkit, Composite parent) {
Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE |
Section.EXPANDED);
GridData gd = new GridData(GridData.FILL_BOTH);
@@ -322,20 +443,20 @@
for (int i = 0; i < readerTypeList.size(); i++) {
Object r = readerTypeList.get(i);
if (r instanceof EObject) {
- if ( CSV12Reader.class.isInstance(reader)) {
- if ( CSV12Reader.class.isInstance(r)) {
+ if (CSV12Reader.class.isInstance(reader)) {
+ if (CSV12Reader.class.isInstance(r)) {
readerCombo.select(i);
break;
}
}
- if ( EDI12Reader.class.isInstance(reader)) {
+ if (EDI12Reader.class.isInstance(reader)) {
if (EDI12Reader.class.isInstance(r)) {
readerCombo.select(i);
break;
}
}
- if ( Json12Reader.class.isInstance(reader)) {
- if ( Json12Reader.class.isInstance(r)) {
+ if (Json12Reader.class.isInstance(reader)) {
+ if (Json12Reader.class.isInstance(r)) {
readerCombo.select(i);
break;
}
@@ -389,7 +510,7 @@
if (SmooksModelUtils.INPUT_TYPE_CSV.equals(inputType)) {
if (!rlist.getAbstractReader().isEmpty()) {
AbstractReader reader = rlist.getAbstractReader().get(0);
- if ( CSV12Reader.class.isInstance(reader)) {
+ if (CSV12Reader.class.isInstance(reader)) {
selectCorrectReaderItem(reader);
}
}
@@ -397,7 +518,7 @@
if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(inputType)) {
if (!rlist.getAbstractReader().isEmpty()) {
AbstractReader reader = rlist.getAbstractReader().get(0);
- if ( EDI12Reader.class.isInstance(reader)) {
+ if (EDI12Reader.class.isInstance(reader)) {
selectCorrectReaderItem(reader);
}
}
@@ -405,7 +526,7 @@
if (SmooksModelUtils.INPUT_TYPE_JSON_1_1.equals(inputType)) {
if (!rlist.getAbstractReader().isEmpty()) {
AbstractReader reader = rlist.getAbstractReader().get(0);
- if ( Json12Reader.class.isInstance(reader)) {
+ if (Json12Reader.class.isInstance(reader)) {
selectCorrectReaderItem(reader);
}
}
@@ -497,13 +618,13 @@
if (reader instanceof EObject) {
Object obj = ((EObject) reader);
- if ( obj instanceof CSV12Reader) {
+ if (obj instanceof CSV12Reader) {
return SmooksModelUtils.INPUT_TYPE_CSV;
}
if (obj instanceof EDI12Reader) {
return SmooksModelUtils.INPUT_TYPE_EDI_1_1;
}
- if ( obj instanceof Json12Reader) {
+ if (obj instanceof Json12Reader) {
return SmooksModelUtils.INPUT_TYPE_JSON_1_1;
}
if (obj instanceof ReaderType) {
@@ -816,42 +937,14 @@
if (c.canExecute())
compoundCommand.append(c);
}
- // getEditingDomain().getCommandStack().execute(setCommand);
- // command.append(c);
- // boolean newOne = true;
- // for (Iterator<?> iterator = params.iterator();
- // iterator.hasNext();) {
- // ParamType paramType = (ParamType) iterator.next();
- // if
- // (SmooksModelUtils.PARAM_NAME_ACTIVED.equals(paramType.getName()))
- // {
- // Command setCommand =
- // SetCommand.create(getEditingDomain(), paramType,
- // GraphPackage.Literals.PARAM_TYPE__VALUE,
- // String.valueOf(checked));
- // getEditingDomain().getCommandStack().execute(setCommand);
- // newOne = false;
- // break;
- // }
- // }
- // if (newOne) {
- // ParamType p = GraphFactory.eINSTANCE.createParamType();
- // p.setName(SmooksModelUtils.PARAM_NAME_ACTIVED);
- // p.setValue(String.valueOf(checked));
- // Command addCommand =
- // AddCommand.create(getEditingDomain(), inputType,
- // GraphPackage.Literals.INPUT_TYPE__PARAM, p);
- // getEditingDomain().getCommandStack().execute(addCommand);
- // inputType.getParam().add(p);
- // }
Object[] checkedObjects = inputDataViewer.getCheckedElements();
for (int i = 0; i < checkedObjects.length; i++) {
InputType type = (InputType) checkedObjects[i];
- type.setActived(!checked);
if (type == inputType) {
continue;
}
+ type.setActived(!checked);
ParamType param1 = SmooksUIUtils.getInputTypeAssociatedParamType(type,
getSmooksConfigResourceList());
if (param1 != null) {
@@ -876,11 +969,13 @@
compoundCommand.append(c);
}
}
+ try {
+ getEditingDomain().getCommandStack().execute(compoundCommand);
+ } catch (Exception e) {
+ // e.printStackTrace();
+ }
- getEditingDomain().getCommandStack().execute(compoundCommand);
- // inputTypeChanged();
- refreshInputModelView();
-
+ // refreshInputModelView();
}
});
inputDataViewer.addDoubleClickListener(new IDoubleClickListener() {
@@ -997,7 +1092,10 @@
if (!inputs.isEmpty()) {
List<?> viewerInput = (List<?>) inputDataViewer.getInput();
viewerInput.removeAll(inputs);
- inputTypeChanged();
+ // inputTypeChanged();
+ if (inputDataViewer != null) {
+ inputDataViewer.refresh();
+ }
}
}
}
@@ -1079,14 +1177,27 @@
}
private void refreshInputModelView() {
+ if (this.getManagedForm() != null) {
+ this.getManagedForm().getMessageManager().removeAllMessages();
+ }
if (inputModelViewer != null) {
List<Object> input = generateInputData();
try {
inputModelViewer.setInput(input);
- } catch (Exception e) {
- e.printStackTrace();
+ SmooksUIUtils.expandSelectorViewer(input, inputModelViewer);
+ } catch (Throwable e) {
+
}
- SmooksUIUtils.expandSelectorViewer(input, inputModelViewer);
+
+ if (input == null || input.isEmpty()) {
+ Throwable t = SelectorCreationDialog.getCurrentException();
+ if (t != null) {
+ if (this.getManagedForm() != null) {
+ this.getManagedForm().getMessageManager().addMessage("input error",
+ "Input Error : " + t.getMessage(), null, IMessageProvider.ERROR);
+ }
+ }
+ }
}
}
@@ -1193,12 +1304,12 @@
if (reader instanceof EObject) {
Object obj = ((EObject) reader);
obj = AdapterFactoryEditingDomain.unwrap(obj);
- if ( obj instanceof EDI12Reader) {
+ if (obj instanceof EDI12Reader) {
if (!SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(type)) {
return true;
}
}
- if ( obj instanceof CSV12Reader) {
+ if (obj instanceof CSV12Reader) {
if (!SmooksModelUtils.INPUT_TYPE_CSV.equals(type)) {
return true;
}
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-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -135,15 +135,15 @@
// SmooksResourceConfiguration readerConfig = new
// SmooksResourceConfiguration("org.xml.sax.driver",
// CSVReader.class.getName());
- if ((quoteChar == null) || (encoding == null) || (fields == null)) {
- return null;
- }
- if (quoteChar == null)
- quoteChar = "\""; //$NON-NLS-1$
- if (skiplines == null)
- skiplines = "0"; //$NON-NLS-1$
- if (encoding == null)
- encoding = "UTF-8"; //$NON-NLS-1$
+// if ((quoteChar == null) || (encoding == null) || (fields == null)) {
+// return null;
+// }
+// if (quoteChar == null)
+// quoteChar = "\""; //$NON-NLS-1$
+// if (skiplines == null)
+// skiplines = "0"; //$NON-NLS-1$
+// if (encoding == null)
+// encoding = "UTF-8"; //$NON-NLS-1$
CSVReaderConfigurator readerConfigurator = new CSVReaderConfigurator(fields);
if (separator != null && separator.length() >= 1) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -170,8 +170,9 @@
// SmooksResourceConfiguration("org.xml.sax.driver",
// SmooksEDIReader.class.getName());
- if (mappingModel == null)
- return null;
+ if (mappingModel == null){
+ throw new RuntimeException("EDI Mapping file can't be empty");
+ }
// If the MappingModel is absolute file path :
File f = new File(mappingModel);
String modelPath = mappingModel;
@@ -211,7 +212,7 @@
ediFileEncoding = "UTF-8"; //$NON-NLS-1$
}
// readerConfig.
- // readerConfig.setParameter("encoding", ediFileEncoding);
+// readerConfig.setParameter("encoding", ediFileEncoding);
smooks.setReaderConfig(readerConfig);
// SmooksUtil.registerResource(readerConfig, smooks);
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-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -64,24 +64,26 @@
Map<String, String> keyMap = new HashMap<String, String>();
if (readerObj == null)
return null;
-// 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 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;
@@ -199,7 +201,11 @@
// Filter the message through Smooks and capture the result as a DOM in
// the domResult instance...
- smooks.filterSource(new StreamSource(inputStream), result);
+ try {
+ smooks.filterSource(new StreamSource(inputStream), result);
+ } catch (Exception t) {
+ throw new RuntimeException(t);
+ }
XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
ByteArrayInputStream byteinputStream = new
ByteArrayInputStream(result.getResult().getBytes());
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java 2009-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -12,6 +12,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
@@ -30,7 +31,12 @@
public TagList analyze(String xmlFilePath,String[] ignoreNodeNames)
throws FileNotFoundException, DocumentException {
FileInputStream stream = new FileInputStream(xmlFilePath);
- return this.analyze(stream,ignoreNodeNames);
+ TagList list = this.analyze(stream,ignoreNodeNames);
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ return list;
}
public TagList analyze(InputStream stream , String[] ignoreNodeNames) throws
DocumentException {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -16,6 +16,7 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -56,6 +57,7 @@
import org.jboss.tools.smooks.model.freemarker.Freemarker;
import org.jboss.tools.smooks.model.freemarker.Template;
import org.jboss.tools.smooks.model.javabean12.BeanType;
+import org.jboss.tools.smooks.model.smooks.ParamType;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
import org.w3c.dom.Document;
@@ -76,6 +78,25 @@
// TODO Auto-generated constructor stub
}
+ protected void autoLayoutWhenCommandChange(Command command) {
+ Collection<?> affectedObjects = command.getAffectedObjects();
+ for (Iterator<?> iterator2 = affectedObjects.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+ if (object instanceof ParamType) {
+ Object parent = ((ParamType) object).eContainer();
+ if (SmooksModelUtils.KEY_CSV_FIELDS.equals(((ParamType) object).getName())) {
+ if (parent instanceof Freemarker) {
+ TaskType task = this.getTaskType();
+ if (task != null && task.inTheTask(parent)) {
+ autoLayout(true);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
/*
* (non-Javadoc)
*
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -26,6 +26,7 @@
import org.eclipse.draw2d.graph.Edge;
import org.eclipse.draw2d.graph.Node;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.common.command.CommandWrapper;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.Diagnostic;
@@ -109,9 +110,9 @@
import org.jboss.tools.smooks.graphical.editors.process.TaskType;
import org.jboss.tools.smooks.model.javabean12.BeanType;
import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+import org.jboss.tools.smooks.model.smooks.AbstractReader;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
import org.jboss.tools.smooks.model.smooks.ParamType;
-import org.jboss.tools.smooks.model.smooks.ParamsType;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
import org.jboss.tools.smooks.model.validation10.RuleType;
@@ -122,6 +123,8 @@
public class SmooksGraphicalEditorPart extends GraphicalEditor implements
ISelectionChangedListener,
ISourceSynchronizeListener, IGraphicalEditorPart, ITaskNodeProvider,
ISmooksModelValidateListener {
+ private CommandStackListener emfCommandStackListener = null;
+
public static final int EXECUTE_COMMAND = 0;
public static final int REDO_COMMAND = 1;
@@ -182,48 +185,12 @@
});
this.smooksModelProvider = provider;
this.setEditDomain(editDomain);
- }
- /**
- * @return the taskType
- */
- public TaskType getTaskType() {
- return taskType;
+ this.createEMFCommandStackListener();
}
- /**
- * @param taskType
- * the taskType to set
- */
- public void setTaskType(TaskType taskType) {
- this.taskType = taskType;
- }
-
- @Override
- public void createPartControl(Composite parent) {
-
- IEditorSite site = getEditorSite();
- if (site instanceof SmooksTaskDetailsEditorSite) {
- FormPage page = ((SmooksTaskDetailsEditorSite) site).getParentEditor();
- FormToolkit tool = page.getManagedForm().getToolkit();
- Composite mainComposite = tool.createComposite(parent);
- mainComposite.setBackground(tool.getColors().getBorderColor());
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginHeight = 1;
- fillLayout.marginWidth = 1;
- mainComposite.setLayout(fillLayout);
- super.createPartControl(mainComposite);
- return;
- }
- super.createPartControl(parent);
- }
-
- public GraphicalViewer getGraphicalViewer() {
- return super.getGraphicalViewer();
- }
-
- private void handleCommandStack(org.eclipse.emf.common.command.CommandStack
commandStack) {
- commandStack.addCommandStackListener(new
org.eclipse.emf.common.command.CommandStackListener() {
+ private void createEMFCommandStackListener() {
+ emfCommandStackListener = new org.eclipse.emf.common.command.CommandStackListener() {
public void commandStackChanged(EventObject event) {
final Command mostRecentCommand = ((org.eclipse.emf.common.command.CommandStack)
event.getSource())
.getMostRecentCommand();
@@ -272,9 +239,119 @@
});
}
- });
+ };
}
+ /**
+ * @return the taskType
+ */
+ public TaskType getTaskType() {
+ return taskType;
+ }
+
+ /**
+ * @param taskType
+ * the taskType to set
+ */
+ public void setTaskType(TaskType taskType) {
+ this.taskType = taskType;
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+
+ IEditorSite site = getEditorSite();
+ if (site instanceof SmooksTaskDetailsEditorSite) {
+ FormPage page = ((SmooksTaskDetailsEditorSite) site).getParentEditor();
+ FormToolkit tool = page.getManagedForm().getToolkit();
+ Composite mainComposite = tool.createComposite(parent);
+ mainComposite.setBackground(tool.getColors().getBorderColor());
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginHeight = 1;
+ fillLayout.marginWidth = 1;
+ mainComposite.setLayout(fillLayout);
+ super.createPartControl(mainComposite);
+ return;
+ }
+ super.createPartControl(parent);
+ }
+
+ public GraphicalViewer getGraphicalViewer() {
+ return super.getGraphicalViewer();
+ }
+
+ private void handleCommandStack(org.eclipse.emf.common.command.CommandStack
commandStack) {
+ if (emfCommandStackListener != null) {
+ commandStack.addCommandStackListener(emfCommandStackListener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.ui.parts.GraphicalEditor#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (smooksModelProvider != null) {
+ smooksModelProvider.getEditingDomain().getCommandStack()
+ .removeCommandStackListener(emfCommandStackListener);
+ }
+ super.dispose();
+ }
+
+ protected void autoLayoutWhenCommandChange(Command command) {
+ Collection<?> affectedObjects = command.getAffectedObjects();
+ boolean refreshInputModel = false;
+ for (Iterator<?> iterator2 = affectedObjects.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+ if (command instanceof AddCommand) {
+ if (needToLayoutWhenAddModel(object)) {
+ refreshInputModel = true;
+ break;
+ }
+ }
+
+ Collection<?> deletedObjs = null;
+ // if(command instanceof AddCommand){
+ // deletedObjs = ((AddCommand)command).getCollection();
+ // }
+ if (command instanceof DeleteCommand) {
+ deletedObjs = ((DeleteCommand) command).getCollection();
+ }
+ if (command instanceof RemoveCommand) {
+ deletedObjs = ((RemoveCommand) command).getCollection();
+ }
+ if (deletedObjs != null) {
+ for (Iterator<?> iterator = deletedObjs.iterator(); iterator.hasNext();) {
+ Object object2 = (Object) iterator.next();
+ if (needToLayoutWhenRemoveModel(object2)) {
+ refreshInputModel = true;
+ break;
+ }
+ // if (needToLayoutWhenAddModel(object2)) {
+ // refreshInputModel = true;
+ // break;
+ // }
+ }
+ }
+ if (refreshInputModel)
+ break;
+ }
+
+ if (refreshInputModel) {
+ autoLayout(true);
+ }
+ }
+
+ protected boolean needToLayoutWhenAddModel(Object model) {
+ return false;
+ }
+
+ protected boolean needToLayoutWhenRemoveModel(Object model) {
+ return false;
+ }
+
protected void handleInputParamChange(Command command) {
Collection<?> affectedObjects = command.getAffectedObjects();
boolean refreshInputModel = false;
@@ -283,26 +360,33 @@
if (object instanceof ParamType) {
if (SmooksUIUtils.isInputParamType((ParamType) object)) {
refreshInputModel = true;
+ break;
}
}
- if (object instanceof ParamsType) {
- Collection<?> deletedObjs = null;
- if (command instanceof DeleteCommand) {
- deletedObjs = ((DeleteCommand) command).getCollection();
- }
- if (command instanceof RemoveCommand) {
- deletedObjs = ((RemoveCommand) command).getCollection();
- }
- if (deletedObjs != null) {
- for (Iterator<?> iterator = deletedObjs.iterator(); iterator.hasNext();) {
- Object object2 = (Object) iterator.next();
- if (object2 instanceof ParamType) {
- if (SmooksUIUtils.isInputParamType((ParamType) object2)) {
- refreshInputModel = true;
- break;
- }
+ if (object instanceof AbstractReader) {
+ refreshInputModel = true;
+ break;
+ }
+ Collection<?> deletedObjs = null;
+ if (command instanceof DeleteCommand) {
+ deletedObjs = ((DeleteCommand) command).getCollection();
+ }
+ if (command instanceof RemoveCommand) {
+ deletedObjs = ((RemoveCommand) command).getCollection();
+ }
+ if (deletedObjs != null) {
+ for (Iterator<?> iterator = deletedObjs.iterator(); iterator.hasNext();) {
+ Object object2 = (Object) iterator.next();
+ if (object2 instanceof ParamType) {
+ if (SmooksUIUtils.isInputParamType((ParamType) object2)) {
+ refreshInputModel = true;
+ break;
}
}
+ if (object2 instanceof AbstractReader) {
+ refreshInputModel = true;
+ break;
+ }
}
}
if (refreshInputModel)
@@ -641,6 +725,7 @@
continue;
}
}
+ autoLayoutWhenCommandChange(command);
}
private AbstractSmooksGraphicalModel findGraphicalModel(Object object) {
@@ -1316,6 +1401,7 @@
createConnection(inputGraphModel, connections);
expandConnectedModels(connections);
}
+ autoLayout();
}
}
@@ -1369,7 +1455,7 @@
if (datas.size() == 2) {
Object parentObj = datas.get(0);
- if (parentObj instanceof BeanType ) {
+ if (parentObj instanceof BeanType) {
Object obj = datas.get(1);
if (obj == Javabean12Package.Literals.BEAN_TYPE__BEAN_ID) {
String message = diagnostic.getMessage();
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java 2009-12-04
02:19:33 UTC (rev 19038)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java 2009-12-04
02:29:39 UTC (rev 19039)
@@ -41,6 +41,36 @@
// TODO Auto-generated constructor stub
}
+
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#needToLayoutWhenAddModel(java.lang.Object)
+ */
+ @Override
+ protected boolean needToLayoutWhenAddModel(Object model) {
+ model = AdapterFactoryEditingDomain.unwrap(model);
+ if(model instanceof BeanType){
+ return true;
+ }
+ return super.needToLayoutWhenAddModel(model);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#needToLayoutWhenRemoveModel(java.lang.Object)
+ */
+ @Override
+ protected boolean needToLayoutWhenRemoveModel(Object model) {
+ model = AdapterFactoryEditingDomain.unwrap(model);
+ if(model instanceof BeanType){
+ return true;
+ }
+ return super.needToLayoutWhenRemoveModel(model);
+ }
+
+
+
/*
* (non-Javadoc)
*