Author: DartPeng
Date: 2009-12-03 21:19:33 -0500 (Thu, 03 Dec 2009)
New Revision: 19038
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/provider/SmooksResourceListTypeItemProvider.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java
Log:
JBIDE-5368
Done
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/provider/SmooksResourceListTypeItemProvider.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/smooks/provider/SmooksResourceListTypeItemProvider.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -16,6 +16,8 @@
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;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -55,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;
@@ -75,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)
*
@@ -88,6 +110,79 @@
return factory;
}
+ @Override
+ public void validateEnd(List<Diagnostic> diagnosticResult) {
+ cleanValidationMarker();
+ // validate freemarker model.Because the freemarker csv node
+ // model isn't EMF model so they need to validate separately
+ if (root == null)
+ return;
+ List<AbstractSmooksGraphicalModel> children = root.getChildren();
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator.next();
+ if (abstractSmooksGraphicalModel instanceof FreemarkerTemplateGraphicalModel) {
+ Object data = abstractSmooksGraphicalModel.getData();
+ data = AdapterFactoryEditingDomain.unwrap(data);
+ if (data instanceof Freemarker) {
+ String type = SmooksModelUtils.getTemplateType((Freemarker) data);
+ if (SmooksModelUtils.FREEMARKER_TEMPLATE_TYPE_CSV.equals(type)) {
+ validateCSVTemplate(abstractSmooksGraphicalModel);
+ }
+ }
+ }
+ }
+ }
+
+ protected void validateCSVTemplate(AbstractSmooksGraphicalModel templateGraphModel) {
+ int s = AbstractSmooksGraphicalModel.NONE;
+ Object data = templateGraphModel.getData();
+ data = AdapterFactoryEditingDomain.unwrap(data);
+
+ char seperator = SmooksModelUtils.getFreemarkerCSVSeperator((Freemarker) data);
+
+ if (seperator == 0) {
+ templateGraphModel.getMessage().add("Seperator character can't be
empty");
+ s = AbstractSmooksGraphicalModel.WARNING;
+ }
+
+ char quote = SmooksModelUtils.getFreemarkerCSVQuote((Freemarker) data);
+ if (quote == 0) {
+ templateGraphModel.getMessage().add("Quote character can't be empty");
+ s = AbstractSmooksGraphicalModel.WARNING;
+ }
+
+ String[] fields = SmooksModelUtils.getFreemarkerCSVFileds((Freemarker) data);
+ boolean missFields = false;
+ if (fields == null) {
+ missFields = true;
+ }
+
+ if (s != AbstractSmooksGraphicalModel.NONE) {
+ templateGraphModel.setSeverity(s);
+ }
+
+ List<AbstractSmooksGraphicalModel> csvRecordNode =
templateGraphModel.getChildren();
+ for (Iterator<?> iterator = csvRecordNode.iterator(); iterator.hasNext();) {
+ AbstractSmooksGraphicalModel csvRecordGraphModel = (AbstractSmooksGraphicalModel)
iterator.next();
+ if (missFields) {
+ csvRecordGraphModel.getMessage().add("CSV fields can't be empty");
+ csvRecordGraphModel.setSeverity(AbstractSmooksGraphicalModel.WARNING);
+ }
+ List<TreeNodeConnection> collectionConnections =
csvRecordGraphModel.getTargetConnections();
+ if (collectionConnections.isEmpty()) {
+ csvRecordGraphModel.addMessage("Must be linked with source node");
+ csvRecordGraphModel.setSeverity(AbstractSmooksGraphicalModel.WARNING);
+ List<AbstractSmooksGraphicalModel> csvFields =
csvRecordGraphModel.getChildren();
+ for (Iterator<?> iterator2 = csvFields.iterator(); iterator2.hasNext();) {
+ AbstractSmooksGraphicalModel csvFieldsGModel = (AbstractSmooksGraphicalModel)
iterator2.next();
+ csvFieldsGModel
+ .addMessage("Case CSV-Record isn't linked with source node , this node
can't be linked.");
+ csvFieldsGModel.setSeverity(AbstractSmooksGraphicalModel.ERROR);
+ }
+ }
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -333,26 +428,27 @@
}
}
}
-// if (bean instanceof BindingsType) {
-// List<?> values = ((BindingsType) bean).getValue();
-// for (Iterator<?> iterator = values.iterator(); iterator.hasNext();) {
-// ValueType value = (ValueType) iterator.next();
-// if (propertyName.equals(value.getProperty())) {
-// return value;
-// }
-// }
-// }
+ // if (bean instanceof BindingsType) {
+ // List<?> values = ((BindingsType) bean).getValue();
+ // for (Iterator<?> iterator = values.iterator();
+ // iterator.hasNext();) {
+ // ValueType value = (ValueType) iterator.next();
+ // if (propertyName.equals(value.getProperty())) {
+ // return value;
+ // }
+ // }
+ // }
return null;
}
private Object findJavaBeanModel(String beanid, List<EObject> beans) {
for (Iterator<?> iterator = beans.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
-// if (object instanceof BindingsType) {
-// if (beanid.equals(((BindingsType) object).getBeanId())) {
-// return object;
-// }
-// }
+ // if (object instanceof BindingsType) {
+ // if (beanid.equals(((BindingsType) object).getBeanId())) {
+ // return object;
+ // }
+ // }
if (object instanceof BeanType) {
if (beanid.equals(((BeanType) object).getBeanId())) {
return object;
@@ -374,7 +470,7 @@
char quote = SmooksModelUtils.getFreemarkerCSVQuote(freemarker);
String[] fields = SmooksModelUtils.getFreemarkerCSVFileds(freemarker);
try {
- if(contents != null) {
+ if (contents != null) {
CSVModelBuilder modelBuilder = new CSVModelBuilder(fields);
Document model = modelBuilder.buildModel();
TemplateBuilder builder = new CSVFreeMarkerTemplateBuilder(model, seprator, quote,
contents);
@@ -383,7 +479,7 @@
}
} catch (Exception e) {
// ignore exception
-// e.printStackTrace();
+ // e.printStackTrace();
}
}
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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;
@@ -119,10 +120,11 @@
* @author Dart
*
*/
-public class SmooksGraphicalEditorPart extends GraphicalEditor implements
- ISelectionChangedListener, ISourceSynchronizeListener,
- IGraphicalEditorPart, ITaskNodeProvider, ISmooksModelValidateListener {
+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;
@@ -175,17 +177,71 @@
}
});
- this.editDomain.getCommandStack().addCommandStackEventListener(
- new CommandStackEventListener() {
+ this.editDomain.getCommandStack().addCommandStackEventListener(new
CommandStackEventListener() {
- public void stackChanged(CommandStackEvent event) {
- firePropertyChange(PROP_DIRTY);
- }
- });
+ public void stackChanged(CommandStackEvent event) {
+ firePropertyChange(PROP_DIRTY);
+ }
+ });
this.smooksModelProvider = provider;
this.setEditDomain(editDomain);
+
+ this.createEMFCommandStackListener();
}
+ 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();
+ final EventObject fe = event;
+ getEditorSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (mostRecentCommand != null) {
+ Command rawCommand = mostRecentCommand;
+ while (rawCommand instanceof CommandWrapper) {
+ rawCommand = ((CommandWrapper) rawCommand).getCommand();
+ }
+ int commandType = EXECUTE_COMMAND;
+ Command undoCommand = ((org.eclipse.emf.common.command.CommandStack)
fe.getSource())
+ .getUndoCommand();
+ Command redoCommand = ((org.eclipse.emf.common.command.CommandStack)
fe.getSource())
+ .getRedoCommand();
+ if (undoCommand != null || rawCommand.equals(undoCommand)) {
+ commandType = EXECUTE_COMMAND;
+ }
+ if (redoCommand != null || rawCommand.equals(redoCommand)) {
+ commandType = UNDO_COMMAND;
+ }
+ if (rawCommand instanceof CompoundCommand) {
+ List<Command> commandList = ((CompoundCommand)
rawCommand).getCommandList();
+ for (Iterator<?> iterator = commandList.iterator(); iterator.hasNext();) {
+ Command command = (Command) iterator.next();
+ while (command instanceof CommandWrapper) {
+ command = ((CommandWrapper) command).getCommand();
+ }
+ handleInputParamChange(command);
+ if (command instanceof SetCommand || command instanceof AddCommand
+ || command instanceof DeleteCommand || command instanceof RemoveCommand) {
+ refershRecentAffectedModel(command, command.getAffectedObjects(),
commandType);
+ }
+ }
+ } else {
+ if (rawCommand instanceof SetCommand || rawCommand instanceof AddCommand
+ || rawCommand instanceof DeleteCommand || rawCommand instanceof RemoveCommand)
{
+ handleInputParamChange(rawCommand);
+ refershRecentAffectedModel(rawCommand, mostRecentCommand.getAffectedObjects(),
+ commandType);
+ }
+ }
+ }
+ }
+
+ });
+ }
+ };
+ }
+
/**
* @return the taskType
*/
@@ -206,8 +262,7 @@
IEditorSite site = getEditorSite();
if (site instanceof SmooksTaskDetailsEditorSite) {
- FormPage page = ((SmooksTaskDetailsEditorSite) site)
- .getParentEditor();
+ FormPage page = ((SmooksTaskDetailsEditorSite) site).getParentEditor();
FormToolkit tool = page.getManagedForm().getToolkit();
Composite mainComposite = tool.createComposite(parent);
mainComposite.setBackground(tool.getColors().getBorderColor());
@@ -225,116 +280,113 @@
return super.getGraphicalViewer();
}
- private void handleCommandStack(
- org.eclipse.emf.common.command.CommandStack commandStack) {
- commandStack
- .addCommandStackListener(new org.eclipse.emf.common.command.CommandStackListener() {
- public void commandStackChanged(EventObject event) {
- final Command mostRecentCommand = ((org.eclipse.emf.common.command.CommandStack)
event
- .getSource()).getMostRecentCommand();
- final EventObject fe = event;
- getEditorSite().getShell().getDisplay().asyncExec(
- new Runnable() {
- public void run() {
- if (mostRecentCommand != null) {
- Command rawCommand = mostRecentCommand;
- while (rawCommand instanceof CommandWrapper) {
- rawCommand = ((CommandWrapper) rawCommand)
- .getCommand();
- }
- int commandType = EXECUTE_COMMAND;
- Command undoCommand = ((org.eclipse.emf.common.command.CommandStack) fe
- .getSource())
- .getUndoCommand();
- Command redoCommand = ((org.eclipse.emf.common.command.CommandStack) fe
- .getSource())
- .getRedoCommand();
- if (undoCommand != null
- || rawCommand
- .equals(undoCommand)) {
- commandType = EXECUTE_COMMAND;
- }
- if (redoCommand != null
- || rawCommand
- .equals(redoCommand)) {
- commandType = UNDO_COMMAND;
- }
- if (rawCommand instanceof CompoundCommand) {
- List<Command> commandList = ((CompoundCommand) rawCommand)
- .getCommandList();
- for (Iterator<?> iterator = commandList
- .iterator(); iterator
- .hasNext();) {
- Command command = (Command) iterator
- .next();
- while (command instanceof CommandWrapper) {
- command = ((CommandWrapper) command)
- .getCommand();
- }
- handleInputParamChange(command);
- if (command instanceof SetCommand
- || command instanceof AddCommand
- || command instanceof DeleteCommand
- || command instanceof RemoveCommand) {
- refershRecentAffectedModel(
- command,
- command
- .getAffectedObjects(),
- commandType);
- }
- }
- } else {
- if (rawCommand instanceof SetCommand
- || rawCommand instanceof AddCommand
- || rawCommand instanceof DeleteCommand
- || rawCommand instanceof RemoveCommand) {
- handleInputParamChange(rawCommand);
- refershRecentAffectedModel(
- rawCommand,
- mostRecentCommand
- .getAffectedObjects(),
- commandType);
- }
- }
- }
- }
+ 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;
- for (Iterator<?> iterator2 = affectedObjects.iterator(); iterator2
- .hasNext();) {
+ for (Iterator<?> iterator2 = affectedObjects.iterator(); iterator2.hasNext();) {
Object object = (Object) iterator2.next();
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)
@@ -358,8 +410,7 @@
return new ConnectionModelFactoryImpl();
}
- public void setConnectionModelFactory(
- ConnectionModelFactory connectionModelFactory) {
+ public void setConnectionModelFactory(ConnectionModelFactory connectionModelFactory) {
this.connectionModelFactory = connectionModelFactory;
}
@@ -374,8 +425,7 @@
return new GraphicalModelFactoryImpl();
}
- public void setGraphicalModelFactory(
- GraphicalModelFactoryImpl graphicalModelFactory) {
+ public void setGraphicalModelFactory(GraphicalModelFactoryImpl graphicalModelFactory) {
this.graphicalModelFactory = graphicalModelFactory;
}
@@ -388,37 +438,27 @@
getSelectionActions().add(autoLayout.getId());
}
- private void deleteRelatedConnection(
- AbstractSmooksGraphicalModel effecedNode,
- EStructuralFeature feature, SetCommand command) {
- EObject data = (EObject) AdapterFactoryEditingDomain.unwrap(effecedNode
- .getData());
+ private void deleteRelatedConnection(AbstractSmooksGraphicalModel effecedNode,
EStructuralFeature feature,
+ SetCommand command) {
+ EObject data = (EObject) AdapterFactoryEditingDomain.unwrap(effecedNode.getData());
if (feature.equals(SmooksUIUtils.getBeanIDRefFeature(data))) {
- List<TreeNodeConnection> sourceConnections = effecedNode
- .getSourceConnections();
- List<TreeNodeConnection> temp = new ArrayList<TreeNodeConnection>(
- sourceConnections);
+ List<TreeNodeConnection> sourceConnections =
effecedNode.getSourceConnections();
+ List<TreeNodeConnection> temp = new
ArrayList<TreeNodeConnection>(sourceConnections);
for (Iterator<?> iterator = temp.iterator(); iterator.hasNext();) {
- TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator
- .next();
- AbstractSmooksGraphicalModel target = treeNodeConnection
- .getTargetNode();
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next();
+ AbstractSmooksGraphicalModel target = treeNodeConnection.getTargetNode();
String refID = command.getValue().toString();
- Object targetModel = AdapterFactoryEditingDomain.unwrap(target
- .getData());
+ Object targetModel = AdapterFactoryEditingDomain.unwrap(target.getData());
if (targetModel instanceof EObject) {
- EStructuralFeature idfeature = SmooksUIUtils
- .getBeanIDFeature((EObject) targetModel);
+ EStructuralFeature idfeature = SmooksUIUtils.getBeanIDFeature((EObject)
targetModel);
if (idfeature == null)
continue;
Object iddata = ((EObject) targetModel).eGet(idfeature);
if (iddata != null) {
if (refID == null || !refID.equals(iddata)) {
- target.getTargetConnections().remove(
- treeNodeConnection);
- effecedNode.getSourceConnections().remove(
- treeNodeConnection);
+ target.getTargetConnections().remove(treeNodeConnection);
+ effecedNode.getSourceConnections().remove(treeNodeConnection);
target.fireConnectionChanged();
}
}
@@ -427,31 +467,22 @@
}
if (feature.equals(SmooksUIUtils.getBeanIDFeature(data))) {
- List<TreeNodeConnection> targetConnections = effecedNode
- .getTargetConnections();
- List<TreeNodeConnection> temp = new ArrayList<TreeNodeConnection>(
- targetConnections);
+ List<TreeNodeConnection> targetConnections =
effecedNode.getTargetConnections();
+ List<TreeNodeConnection> temp = new
ArrayList<TreeNodeConnection>(targetConnections);
for (Iterator<?> iterator = temp.iterator(); iterator.hasNext();) {
- TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator
- .next();
- AbstractSmooksGraphicalModel source = treeNodeConnection
- .getSourceNode();
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next();
+ AbstractSmooksGraphicalModel source = treeNodeConnection.getSourceNode();
String beanID = command.getValue().toString();
- Object sourceModel = AdapterFactoryEditingDomain.unwrap(source
- .getData());
+ Object sourceModel = AdapterFactoryEditingDomain.unwrap(source.getData());
if (sourceModel instanceof EObject) {
- EStructuralFeature idRefFeature = SmooksUIUtils
- .getBeanIDRefFeature((EObject) sourceModel);
+ EStructuralFeature idRefFeature = SmooksUIUtils.getBeanIDRefFeature((EObject)
sourceModel);
if (idRefFeature == null)
continue;
- Object idRefData = ((EObject) sourceModel)
- .eGet(idRefFeature);
+ Object idRefData = ((EObject) sourceModel).eGet(idRefFeature);
if (idRefData != null) {
if (beanID == null || !beanID.equals(idRefData)) {
- source.getSourceConnections().remove(
- treeNodeConnection);
- effecedNode.getTargetConnections().remove(
- treeNodeConnection);
+ source.getSourceConnections().remove(treeNodeConnection);
+ effecedNode.getTargetConnections().remove(treeNodeConnection);
source.fireConnectionChanged();
}
}
@@ -460,37 +491,27 @@
}
if (feature.equals(SmooksUIUtils.getSelectorFeature(data))) {
- List<TreeNodeConnection> targetConnections = effecedNode
- .getTargetConnections();
- List<TreeNodeConnection> temp = new ArrayList<TreeNodeConnection>(
- targetConnections);
+ List<TreeNodeConnection> targetConnections =
effecedNode.getTargetConnections();
+ List<TreeNodeConnection> temp = new
ArrayList<TreeNodeConnection>(targetConnections);
for (Iterator<?> iterator = temp.iterator(); iterator.hasNext();) {
- TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator
- .next();
- AbstractSmooksGraphicalModel source = treeNodeConnection
- .getSourceNode();
- if (source instanceof InputDataContianerModel
- || source instanceof InputDataTreeNodeModel) {
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next();
+ AbstractSmooksGraphicalModel source = treeNodeConnection.getSourceNode();
+ if (source instanceof InputDataContianerModel || source instanceof
InputDataTreeNodeModel) {
String selector = command.getValue().toString();
- Object sourceModel = AdapterFactoryEditingDomain
- .unwrap(source.getData());
+ Object sourceModel = AdapterFactoryEditingDomain.unwrap(source.getData());
if (sourceModel instanceof IXMLStructuredObject) {
- IXMLStructuredObject root = SmooksUIUtils
- .getRootParent((IXMLStructuredObject) sourceModel);
+ IXMLStructuredObject root = SmooksUIUtils.getRootParent((IXMLStructuredObject)
sourceModel);
Object oldNode = null;
try {
- oldNode = SmooksUIUtils.localXMLNodeWithPath(
- selector, root);
+ oldNode = SmooksUIUtils.localXMLNodeWithPath(selector, root);
} catch (Throwable t) {
}
if (oldNode == sourceModel) {
break;
} else {
- source.getSourceConnections().remove(
- treeNodeConnection);
- effecedNode.getTargetConnections().remove(
- treeNodeConnection);
+ source.getSourceConnections().remove(treeNodeConnection);
+ effecedNode.getTargetConnections().remove(treeNodeConnection);
source.fireConnectionChanged();
}
}
@@ -500,17 +521,14 @@
}
}
- public AbstractSmooksGraphicalModel findRelatedInputGraphicalModel(
- Object model) {
+ public AbstractSmooksGraphicalModel findRelatedInputGraphicalModel(Object model) {
if (model instanceof RuleType) {
String selector = ((RuleType) model).getExecuteOn();
- for (Iterator<?> iterator = inputDataList.iterator(); iterator
- .hasNext();) {
+ for (Iterator<?> iterator = inputDataList.iterator(); iterator.hasNext();) {
Object inputData = (Object) iterator.next();
if (inputData instanceof IXMLStructuredObject) {
- IXMLStructuredObject node = SmooksUIUtils
- .localXMLNodeWithPath(selector,
- (IXMLStructuredObject) inputData);
+ IXMLStructuredObject node = SmooksUIUtils.localXMLNodeWithPath(selector,
+ (IXMLStructuredObject) inputData);
AbstractSmooksGraphicalModel graphicalModel = findGraphicalModel(node);
return graphicalModel;
}
@@ -526,23 +544,18 @@
* @param affectedObjects
* @param commandType
*/
- protected void refershRecentAffectedModel(Command command,
- Collection<?> affectedObjects, int commandType) {
- for (Iterator<?> iterator = affectedObjects.iterator(); iterator
- .hasNext();) {
+ protected void refershRecentAffectedModel(Command command, Collection<?>
affectedObjects, int commandType) {
+ for (Iterator<?> iterator = affectedObjects.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
object = AdapterFactoryEditingDomain.unwrap(object);
if (commandType == EXECUTE_COMMAND || commandType == REDO_COMMAND) {
if (object instanceof SmooksResourceListType) {
if (command instanceof AddCommand) {
- Collection<?> colletion = ((AddCommand) command)
- .getCollection();
- for (Iterator<?> iterator2 = colletion.iterator(); iterator2
- .hasNext();) {
+ Collection<?> colletion = ((AddCommand) command).getCollection();
+ for (Iterator<?> iterator2 = colletion.iterator(); iterator2.hasNext();) {
Object childModel = (Object) iterator2.next();
- childModel = AdapterFactoryEditingDomain
- .unwrap(childModel);
+ childModel = AdapterFactoryEditingDomain.unwrap(childModel);
AbstractSmooksGraphicalModel inputGraphicalModel =
findRelatedInputGraphicalModel(childModel);
if (inputGraphicalModel != null) {
inputGraphicalModel.fireVisualChanged();
@@ -556,22 +569,17 @@
expandConnectedModels(connections);
}
}
- if (command instanceof DeleteCommand
- || command instanceof RemoveCommand) {
+ if (command instanceof DeleteCommand || command instanceof RemoveCommand) {
Collection<?> colletion = null;
if (command instanceof DeleteCommand) {
- colletion = ((DeleteCommand) command)
- .getCollection();
+ colletion = ((DeleteCommand) command).getCollection();
}
if (command instanceof RemoveCommand) {
- colletion = ((RemoveCommand) command)
- .getCollection();
+ colletion = ((RemoveCommand) command).getCollection();
}
- for (Iterator<?> iterator2 = colletion.iterator(); iterator2
- .hasNext();) {
+ for (Iterator<?> iterator2 = colletion.iterator(); iterator2.hasNext();) {
Object childModel = (Object) iterator2.next();
- childModel = AdapterFactoryEditingDomain
- .unwrap(childModel);
+ childModel = AdapterFactoryEditingDomain.unwrap(childModel);
AbstractSmooksGraphicalModel inputGraphicalModel =
findRelatedInputGraphicalModel(childModel);
if (inputGraphicalModel != null) {
inputGraphicalModel.fireVisualChanged();
@@ -579,8 +587,7 @@
AbstractSmooksGraphicalModel graphModel = findGraphicalModel(childModel);
if (graphModel == null)
continue;
- AbstractSmooksGraphicalModel
- .disconnectAllConnections(graphModel);
+ AbstractSmooksGraphicalModel.disconnectAllConnections(graphModel);
root.removeTreeNode(graphModel);
}
}
@@ -592,11 +599,9 @@
continue;
}
node.fireVisualChanged();
- EStructuralFeature feature = ((SetCommand) command)
- .getFeature();
+ EStructuralFeature feature = ((SetCommand) command).getFeature();
if (SmooksUIUtils.isRelatedConnectionFeature(feature)) {
- deleteRelatedConnection(node, feature,
- (SetCommand) command);
+ deleteRelatedConnection(node, feature, (SetCommand) command);
Collection<TreeNodeConnection> connections = createConnection(node);
node.fireConnectionChanged();
expandConnectedModels(connections);
@@ -633,8 +638,7 @@
node.fireChildrenChanged();
node.fireConnectionChanged();
}
- if (command instanceof DeleteCommand
- || command instanceof RemoveCommand) {
+ if (command instanceof DeleteCommand || command instanceof RemoveCommand) {
AbstractSmooksGraphicalModel inputGraphicalModel =
findRelatedInputGraphicalModel(object);
if (inputGraphicalModel != null) {
inputGraphicalModel.fireVisualChanged();
@@ -652,13 +656,10 @@
AbstractSmooksGraphicalModel node = findGraphicalModel(object);
if (command instanceof AddCommand) {
if (object instanceof SmooksResourceListType) {
- Collection<?> cccc = ((AddCommand) command)
- .getCollection();
- for (Iterator<?> iterator2 = cccc.iterator(); iterator2
- .hasNext();) {
+ Collection<?> cccc = ((AddCommand) command).getCollection();
+ for (Iterator<?> iterator2 = cccc.iterator(); iterator2.hasNext();) {
Object object2 = (Object) iterator2.next();
- object2 = AdapterFactoryEditingDomain
- .unwrap(object2);
+ object2 = AdapterFactoryEditingDomain.unwrap(object2);
AbstractSmooksGraphicalModel gmodel = findGraphicalModel(object2);
if (gmodel != null) {
root.removeTreeNode(gmodel);
@@ -676,18 +677,15 @@
continue;
}
node.fireVisualChanged();
- EStructuralFeature feature = ((SetCommand) command)
- .getFeature();
+ EStructuralFeature feature = ((SetCommand) command).getFeature();
if (SmooksUIUtils.isRelatedConnectionFeature(feature)) {
- deleteRelatedConnection(node, feature,
- (SetCommand) command);
+ deleteRelatedConnection(node, feature, (SetCommand) command);
Collection<TreeNodeConnection> connections = createConnection(node);
node.fireConnectionChanged();
expandConnectedModels(connections);
}
}
- if (command instanceof DeleteCommand
- || command instanceof RemoveCommand) {
+ if (command instanceof DeleteCommand || command instanceof RemoveCommand) {
Collection<?> cccc = null;
if (command instanceof DeleteCommand) {
cccc = ((DeleteCommand) command).getCollection();
@@ -695,16 +693,14 @@
if (command instanceof RemoveCommand) {
cccc = ((RemoveCommand) command).getCollection();
}
- for (Iterator<?> iterator2 = cccc.iterator(); iterator2
- .hasNext();) {
+ for (Iterator<?> iterator2 = cccc.iterator(); iterator2.hasNext();) {
Object object2 = (Object) iterator2.next();
object2 = AdapterFactoryEditingDomain.unwrap(object2);
// it means that it's deletecommand undo
if (object == object2) {
EObject owner = ((EObject) object).eContainer();
if (owner instanceof SmooksResourceListType) {
- object = AdapterFactoryEditingDomain
- .unwrap(object);
+ object = AdapterFactoryEditingDomain.unwrap(object);
AbstractSmooksGraphicalModel graphModel = createGraphModel(object);
if (graphModel == null)
continue;
@@ -729,6 +725,7 @@
continue;
}
}
+ autoLayoutWhenCommandChange(command);
}
private AbstractSmooksGraphicalModel findGraphicalModel(Object object) {
@@ -756,22 +753,18 @@
getGraphicalViewer().setEditDomain(editDomain);
getGraphicalViewer().setEditPartFactory(createEdtiPartFactory());
- getGraphicalViewer().setRootEditPart(
- new FreeformGraphicalRootEditPart() {
- public DragTracker getDragTracker(Request req) {
- return new RightClickSelectMarqueeDragTraker();
- }
- });
+ getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart() {
+ public DragTracker getDragTracker(Request req) {
+ return new RightClickSelectMarqueeDragTraker();
+ }
+ });
- getGraphicalViewer()
- .addDropTargetListener(
- (TransferDropTargetListener) new TemplateTransferDropTargetListener(
- getGraphicalViewer()));
+ getGraphicalViewer().addDropTargetListener(
+ (TransferDropTargetListener) new
TemplateTransferDropTargetListener(getGraphicalViewer()));
- GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(
- getGraphicalViewer());
- keyHandler.put(org.eclipse.gef.KeyStroke.getPressed(SWT.DEL, 0), this
- .getActionRegistry().getAction(ActionFactory.DELETE.getId()));
+ GraphicalViewerKeyHandler keyHandler = new
GraphicalViewerKeyHandler(getGraphicalViewer());
+ keyHandler.put(org.eclipse.gef.KeyStroke.getPressed(SWT.DEL, 0),
this.getActionRegistry().getAction(
+ ActionFactory.DELETE.getId()));
ContextMenuProvider provider = getContextMenuProvider();
getGraphicalViewer().setContextMenu(provider);
@@ -780,8 +773,7 @@
}
protected ContextMenuProvider getContextMenuProvider() {
- return new SmooksGraphicalEditorMenuContextProvider(
- getGraphicalViewer(), this.getActionRegistry());
+ return new SmooksGraphicalEditorMenuContextProvider(getGraphicalViewer(),
this.getActionRegistry());
}
private void hookSelectionActions() {
@@ -789,8 +781,7 @@
while (actions.hasNext()) {
Object action = actions.next();
if (action instanceof SelectionAction) {
- ((SelectionAction) action)
- .setSelectionProvider(getGraphicalViewer());
+ ((SelectionAction) action).setSelectionProvider(getGraphicalViewer());
}
}
}
@@ -798,8 +789,7 @@
protected List<AbstractSmooksGraphicalModel> createInputDataGraphModel() {
List<AbstractSmooksGraphicalModel> inputGraphModel = new
ArrayList<AbstractSmooksGraphicalModel>();
if (inputDataList != null && root != null) {
- for (Iterator<?> iterator = inputDataList.iterator(); iterator
- .hasNext();) {
+ for (Iterator<?> iterator = inputDataList.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
ITreeContentProvider contentProvider = new XMLStructuredDataContentProvider();
ILabelProvider labelProvider = new XMLStructuredDataLabelProvider();
@@ -812,9 +802,8 @@
}
containerModel.getChildren().add((IXMLStructuredObject) object);
if (containerModel != null) {
- TreeContainerModel container = new InputDataContianerModel(
- containerModel, contentProvider, labelProvider,
- getSmooksModelProvider());
+ TreeContainerModel container = new InputDataContianerModel(containerModel,
contentProvider,
+ labelProvider, getSmooksModelProvider());
root.addTreeNode(container);
inputGraphModel.add(container);
}
@@ -826,8 +815,7 @@
@Override
protected void hookGraphicalViewer() {
super.hookGraphicalViewer();
- getGraphicalViewer().addSelectionChangedListener(
- getSelectionSynchronizer());
+ getGraphicalViewer().addSelectionChangedListener(getSelectionSynchronizer());
getGraphicalViewer().addSelectionChangedListener(this);
}
@@ -843,11 +831,9 @@
return;
AdapterFactoryEditingDomain editingDomain = (AdapterFactoryEditingDomain)
smooksModelProvider
.getEditingDomain();
- if (inputDataList != null && obj != null && obj instanceof
DocumentRoot
- && editingDomain != null) {
+ if (inputDataList != null && obj != null && obj instanceof DocumentRoot
&& editingDomain != null) {
createInputDataGraphModel();
- SmooksResourceListType listType = ((DocumentRoot) obj)
- .getSmooksResourceList();
+ SmooksResourceListType listType = ((DocumentRoot) obj).getSmooksResourceList();
List<?> arcList = listType.getAbstractResourceConfig();
for (Iterator<?> iterator = arcList.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
@@ -871,18 +857,15 @@
this.autoLayout(false);
- List<Diagnostic> diagnosticList = this.getSmooksModelProvider()
- .getDiagnosticList();
+ List<Diagnostic> diagnosticList =
this.getSmooksModelProvider().getDiagnosticList();
this.validateEnd(diagnosticList);
}
protected AbstractSmooksGraphicalModel createGraphModel(Object model) {
GraphicalModelFactory factory = getGraphicalModelFactory();
if (factory != null) {
- Object gmodel = factory.createGraphicalModel(model,
- smooksModelProvider);
- if (gmodel != null
- && gmodel instanceof AbstractSmooksGraphicalModel) {
+ Object gmodel = factory.createGraphicalModel(model, smooksModelProvider);
+ if (gmodel != null && gmodel instanceof AbstractSmooksGraphicalModel) {
AbstractSmooksGraphicalModel graphicalModel = (AbstractSmooksGraphicalModel) gmodel;
return graphicalModel;
}
@@ -898,8 +881,7 @@
return connections;
}
- protected Collection<TreeNodeConnection> createAllConnection(
- AbstractSmooksGraphicalModel model) {
+ protected Collection<TreeNodeConnection>
createAllConnection(AbstractSmooksGraphicalModel model) {
try {
if (model == null)
return null;
@@ -927,15 +909,13 @@
}
}
- public Collection<TreeNodeConnection> createConnection(
- AbstractSmooksGraphicalModel model) {
+ public Collection<TreeNodeConnection>
createConnection(AbstractSmooksGraphicalModel model) {
ConnectionModelFactory connectionModelFactory = getConnectionModelFactory();
List<TreeNodeConnection> cs = new ArrayList<TreeNodeConnection>();
if (connectionModelFactory != null) {
if (connectionModelFactory.hasConnection(model)) {
- Collection<TreeNodeConnection> cList = connectionModelFactory
- .createConnection(inputDataList,
- getSmooksResourceList(), root, model);
+ Collection<TreeNodeConnection> cList =
connectionModelFactory.createConnection(inputDataList,
+ getSmooksResourceList(), root, model);
if (cList != null) {
cs.addAll(cList);
}
@@ -1023,11 +1003,9 @@
return null;
}
- public void createConnection(List<AbstractSmooksGraphicalModel> children,
- List<TreeNodeConnection> connections) {
+ public void createConnection(List<AbstractSmooksGraphicalModel> children,
List<TreeNodeConnection> connections) {
for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
- AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator
- .next();
+ AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator.next();
if (!(abstractSmooksGraphicalModel instanceof InputDataContianerModel)) {
if (canCreateConnection(abstractSmooksGraphicalModel)) {
Collection<TreeNodeConnection> c =
createConnection(abstractSmooksGraphicalModel);
@@ -1035,8 +1013,7 @@
connections.addAll(c);
}
}
- List<AbstractSmooksGraphicalModel> cchildren = abstractSmooksGraphicalModel
- .getChildren();
+ List<AbstractSmooksGraphicalModel> cchildren =
abstractSmooksGraphicalModel.getChildren();
createConnection(cchildren, connections);
}
}
@@ -1065,59 +1042,46 @@
Object obj = smooksModelProvider.getSmooksModel();
smooksResourceList = null;
if (obj instanceof DocumentRoot) {
- smooksResourceList = ((DocumentRoot) obj)
- .getSmooksResourceList();
- inputDataList = SelectorCreationDialog
- .generateInputData(smooksResourceList);
+ smooksResourceList = ((DocumentRoot) obj).getSmooksResourceList();
+ inputDataList = SelectorCreationDialog.generateInputData(smooksResourceList);
}
}
}
@Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
initSmooksData();
if (smooksModelProvider != null) {
- this.handleCommandStack(smooksModelProvider.getEditingDomain()
- .getCommandStack());
+ this.handleCommandStack(smooksModelProvider.getEditingDomain().getCommandStack());
}
}
- protected void expandConnectedModels(
- Collection<TreeNodeConnection> connections) {
+ protected void expandConnectedModels(Collection<TreeNodeConnection> connections)
{
if (connections == null || connections.isEmpty())
return;
List<TreeNodeModel> expanedTreeNodeList = new ArrayList<TreeNodeModel>();
for (Iterator<?> iterator = connections.iterator(); iterator.hasNext();) {
- TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator
- .next();
- AbstractSmooksGraphicalModel source = treeNodeConnection
- .getSourceNode();
- AbstractSmooksGraphicalModel target = treeNodeConnection
- .getTargetNode();
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next();
+ AbstractSmooksGraphicalModel source = treeNodeConnection.getSourceNode();
+ AbstractSmooksGraphicalModel target = treeNodeConnection.getTargetNode();
Object data = source.getData();
Object data2 = target.getData();
- if (source instanceof TreeNodeModel
- && data instanceof IXMLStructuredObject) {
+ if (source instanceof TreeNodeModel && data instanceof IXMLStructuredObject)
{
expanedTreeNodeList.add((TreeNodeModel) source);
}
- if (target instanceof TreeNodeModel
- && data2 instanceof IXMLStructuredObject) {
+ if (target instanceof TreeNodeModel && data2 instanceof IXMLStructuredObject)
{
expanedTreeNodeList.add((TreeNodeModel) target);
}
}
EditPart rootEditPart = getGraphicalViewer().getContents();
if (rootEditPart != null) {
List<?> childrenEditPart = rootEditPart.getChildren();
- for (Iterator<?> iterator = childrenEditPart.iterator(); iterator
- .hasNext();) {
+ for (Iterator<?> iterator = childrenEditPart.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
Object model = ((EditPart) object).getModel();
- if (object instanceof InputDataContainerEditPart
- || model instanceof XSLTemplateGraphicalModel) {
- SmooksUIUtils.expandGraphTree(expanedTreeNodeList,
- (TreeNodeEditPart) object);
+ if (object instanceof InputDataContainerEditPart || model instanceof
XSLTemplateGraphicalModel) {
+ SmooksUIUtils.expandGraphTree(expanedTreeNodeList, (TreeNodeEditPart) object);
}
// if(model instanceof XSLTemplateGraphicalModel){
// ((TreeNodeEditPart) object).expandNode();
@@ -1142,8 +1106,7 @@
initGraphicalModel();
}
- protected void applyGraphicalInformation(
- AbstractSmooksGraphicalModel graphicalModel) {
+ protected void applyGraphicalInformation(AbstractSmooksGraphicalModel graphicalModel) {
// GraphType graph1 = getSmooksGraphicsExtType().getGraph();
// applyGraphicalInformation(graph1, graphicalModel);
}
@@ -1206,11 +1169,9 @@
Node node = (Node) nodeMap.get(part);
figureList.add(part);
graphAnimation.recordInit(part);
- IMoveableModel graphicalModel = (IMoveableModel) part
- .getModel();
+ IMoveableModel graphicalModel = (IMoveableModel) part.getModel();
map.put(graphicalModel, new Point(node.x, node.y));
- graphAnimation.recordFinal(part, new Rectangle(node.x, node.y,
- 0, 0));
+ graphAnimation.recordFinal(part, new Rectangle(node.x, node.y, 0, 0));
}
if (animation) {
graphAnimation.start(figureList);
@@ -1247,8 +1208,7 @@
return null;
}
- protected DirectedGraph collectionGraphInformation(
- HashMap<Object, Node> nodeMap) {
+ protected DirectedGraph collectionGraphInformation(HashMap<Object, Node> nodeMap)
{
DirectedGraph graph = new DirectedGraph();
if (getGraphicalViewer() == null) {
return graph;
@@ -1271,21 +1231,17 @@
for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
GraphicalEditPart object = (GraphicalEditPart) iterator.next();
- for (Iterator<?> iterator2 = children.iterator(); iterator2
- .hasNext();) {
- GraphicalEditPart testEditPart = (GraphicalEditPart) iterator2
- .next();
+ for (Iterator<?> iterator2 = children.iterator(); iterator2.hasNext();) {
+ GraphicalEditPart testEditPart = (GraphicalEditPart) iterator2.next();
Node node = nodeMap.get(object);
Node testNode = nodeMap.get(testEditPart);
if (node != null && testNode != null) {
- if (hasConnectionAssociation(object, testEditPart,
- SOURCE_CONNECT_TYPE)) {
+ if (hasConnectionAssociation(object, testEditPart, SOURCE_CONNECT_TYPE)) {
Edge edge = new Edge(node, testNode);
edge.data = testEditPart;
graph.edges.add(edge);
}
- if (hasConnectionAssociation(object, testEditPart,
- TARGET_CONNECT_TYPE)) {
+ if (hasConnectionAssociation(object, testEditPart, TARGET_CONNECT_TYPE)) {
Edge edge = new Edge(testNode, node);
graph.edges.add(edge);
}
@@ -1299,12 +1255,10 @@
if (model == editPart.getModel()) {
return true;
}
- AbstractSmooksGraphicalModel grphicalModel = (AbstractSmooksGraphicalModel) editPart
- .getModel();
+ AbstractSmooksGraphicalModel grphicalModel = (AbstractSmooksGraphicalModel)
editPart.getModel();
if (!grphicalModel.getChildrenWithoutDynamic().isEmpty()) {
List<?> children = editPart.getChildren();
- for (Iterator<?> iterator2 = children.iterator(); iterator2
- .hasNext();) {
+ for (Iterator<?> iterator2 = children.iterator(); iterator2.hasNext();) {
GraphicalEditPart gpart = (GraphicalEditPart) iterator2.next();
if (hasAssociation(model, gpart)) {
return true;
@@ -1314,8 +1268,7 @@
return false;
}
- private boolean hasConnectionAssociation(GraphicalEditPart editPart,
- GraphicalEditPart testEditPart, int connectType) {
+ private boolean hasConnectionAssociation(GraphicalEditPart editPart, GraphicalEditPart
testEditPart, int connectType) {
List<?> sourceConnections = null;
if (connectType == SOURCE_CONNECT_TYPE) {
sourceConnections = editPart.getSourceConnections();
@@ -1323,11 +1276,9 @@
if (connectType == TARGET_CONNECT_TYPE) {
sourceConnections = editPart.getTargetConnections();
}
- for (Iterator<?> iterator = sourceConnections.iterator(); iterator
- .hasNext();) {
+ for (Iterator<?> iterator = sourceConnections.iterator(); iterator.hasNext();) {
GraphicalEditPart object = (GraphicalEditPart) iterator.next();
- TreeNodeConnection connection = (TreeNodeConnection) object
- .getModel();
+ TreeNodeConnection connection = (TreeNodeConnection) object.getModel();
Object testModel = null;
if (connectType == SOURCE_CONNECT_TYPE) {
testModel = connection.getTargetNode();
@@ -1339,15 +1290,12 @@
return true;
}
}
- AbstractSmooksGraphicalModel sourceGraphModel = (AbstractSmooksGraphicalModel)
editPart
- .getModel();
+ AbstractSmooksGraphicalModel sourceGraphModel = (AbstractSmooksGraphicalModel)
editPart.getModel();
if (!sourceGraphModel.getChildrenWithoutDynamic().isEmpty()) {
List<?> children = editPart.getChildren();
for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
- GraphicalEditPart childEditPart = (GraphicalEditPart) iterator
- .next();
- if (hasConnectionAssociation(childEditPart, testEditPart,
- connectType)) {
+ GraphicalEditPart childEditPart = (GraphicalEditPart) iterator.next();
+ if (hasConnectionAssociation(childEditPart, testEditPart, connectType)) {
return true;
}
}
@@ -1374,8 +1322,7 @@
*/
@Override
public void doSave(IProgressMonitor monitor) {
- if (getEditDomain() != null
- && getEditDomain().getCommandStack() != null) {
+ if (getEditDomain() != null && getEditDomain().getCommandStack() != null) {
getEditDomain().getCommandStack().flush();
}
}
@@ -1408,8 +1355,7 @@
Object obj = smooksModelProvider.getSmooksModel();
smooksResourceList = null;
if (obj instanceof DocumentRoot) {
- smooksResourceList = ((DocumentRoot) obj)
- .getSmooksResourceList();
+ smooksResourceList = ((DocumentRoot) obj).getSmooksResourceList();
}
return smooksResourceList;
}
@@ -1426,8 +1372,7 @@
public void inputTypeChanged() {
if (root != null && inputDataList != null) {
- List<Object> newInputDataList = SelectorCreationDialog
- .generateInputData(getSmooksResourceListType());
+ List<Object> newInputDataList =
SelectorCreationDialog.generateInputData(getSmooksResourceListType());
List<InputDataContianerModel> inputs = new
ArrayList<InputDataContianerModel>();
List<AbstractSmooksGraphicalModel> children = root.getChildren();
@@ -1436,16 +1381,13 @@
AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator
.next();
if (abstractSmooksGraphicalModel instanceof InputDataContianerModel) {
- inputs
- .add((InputDataContianerModel) abstractSmooksGraphicalModel);
+ inputs.add((InputDataContianerModel) abstractSmooksGraphicalModel);
}
}
for (Iterator<?> iterator = inputs.iterator(); iterator.hasNext();) {
- InputDataContianerModel inputModel = (InputDataContianerModel) iterator
- .next();
- AbstractSmooksGraphicalModel
- .disconnectAllConnections(inputModel);
+ InputDataContianerModel inputModel = (InputDataContianerModel) iterator.next();
+ AbstractSmooksGraphicalModel.disconnectAllConnections(inputModel);
root.removeTreeNode(inputModel);
}
@@ -1459,6 +1401,7 @@
createConnection(inputGraphModel, connections);
expandConnectedModels(connections);
}
+ autoLayout();
}
}
@@ -1471,8 +1414,7 @@
return;
List<AbstractSmooksGraphicalModel> children = root.getChildren();
for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
- AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator
- .next();
+ AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator.next();
cleanValidationMarker(abstractSmooksGraphicalModel);
}
}
@@ -1480,11 +1422,9 @@
protected void cleanValidationMarker(AbstractSmooksGraphicalModel model) {
model.setSeverity(IValidatableModel.NONE);
model.getMessage().clear();
- List<AbstractSmooksGraphicalModel> children = model
- .getChildrenWithoutDynamic();
+ List<AbstractSmooksGraphicalModel> children = model.getChildrenWithoutDynamic();
for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
- AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator
- .next();
+ AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator.next();
cleanValidationMarker(abstractSmooksGraphicalModel);
}
}
@@ -1500,8 +1440,7 @@
public void run() {
cleanValidationMarker();
- for (Iterator<?> iterator = flist.iterator(); iterator
- .hasNext();) {
+ for (Iterator<?> iterator = flist.iterator(); iterator.hasNext();) {
Diagnostic diagnostic = (Diagnostic) iterator.next();
refreshValidateResult(diagnostic);
}
@@ -1520,8 +1459,7 @@
Object obj = datas.get(1);
if (obj == Javabean12Package.Literals.BEAN_TYPE__BEAN_ID) {
String message = diagnostic.getMessage();
- if (message != null
- && message.startsWith("The required feature")) { //$NON-NLS-1$
+ if (message != null && message.startsWith("The required feature"))
{ //$NON-NLS-1$
return Messages.SmooksJavaMappingGraphicalEditor_BeanIdEmptyErrormessage;
}
}
@@ -1531,8 +1469,7 @@
Object obj = datas.get(1);
if (obj == Javabean12Package.Literals.VALUE_TYPE__DATA) {
String message = diagnostic.getMessage();
- if (message != null
- && message.startsWith("The required feature")) { //$NON-NLS-1$
+ if (message != null && message.startsWith("The required feature"))
{ //$NON-NLS-1$
return Messages.SmooksJavaMappingGraphicalEditor_NodeMustLinkWithSource;
}
}
@@ -1540,10 +1477,9 @@
if (parentObj instanceof org.jboss.tools.smooks.model.javabean12.WiringType) {
Object obj = datas.get(1);
- if ( obj == Javabean12Package.Literals.WIRING_TYPE__BEAN_ID_REF) {
+ if (obj == Javabean12Package.Literals.WIRING_TYPE__BEAN_ID_REF) {
String message = diagnostic.getMessage();
- if (message != null
- && message.startsWith("The required feature")) { //$NON-NLS-1$
+ if (message != null && message.startsWith("The required feature"))
{ //$NON-NLS-1$
return Messages.SmooksJavaMappingGraphicalEditor_NodeMustLinkWithJavaBean;
}
}
@@ -1562,8 +1498,7 @@
Object object = (Object) iterator2.next();
object = AdapterFactoryEditingDomain.unwrap(object);
if (object instanceof EObject) {
- AbstractSmooksGraphicalModel graphModel = SmooksGraphUtil
- .findSmooksGraphModel(root, object);
+ AbstractSmooksGraphicalModel graphModel = SmooksGraphUtil.findSmooksGraphModel(root,
object);
if (graphModel == null)
continue;
obj = graphModel;
@@ -1574,8 +1509,7 @@
}
}
if (obj != null) {
- for (Iterator<?> iterator2 = datas.iterator(); iterator2
- .hasNext();) {
+ for (Iterator<?> iterator2 = datas.iterator(); iterator2.hasNext();) {
Object object = (Object) iterator2.next();
object = AdapterFactoryEditingDomain.unwrap(object);
if (object instanceof EAttribute && obj != null) {
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java 2009-12-04
01:45:37 UTC (rev 19037)
+++
branches/jbosstools-3.1.0.RC1/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)
@@ -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)
*