Author: DartPeng
Date: 2009-07-14 06:23:19 -0400 (Tue, 14 Jul 2009)
New Revision: 16561
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIDataContainerModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileConfigPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileContainerSelectionPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeConnectionEditPolicy.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeEndpointEditPolicy.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ModelPanelCreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/FieldUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentsUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SubComponentUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/actions/RenameXmlTagNameCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIFileParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/AbstractEDIMappingEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeContainerGraphModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java
Log:
JBIDE-4592
1. Add EDI config file wizard
2. Delete/Connect nodes
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-07-14 08:14:39 UTC (rev
16560)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-07-14 10:23:19 UTC (rev
16561)
@@ -37,6 +37,13 @@
class="org.jboss.tools.smooks.configuration.wizards.SmooksConfigurationFileNewWizard"
id="org.jboss.tools.smooks.configuration.wizards.NewConfigurationFileWizard">
</wizard>
+ <wizard
+ category="org.jboss.tools.smooks.configuration"
+
class="org.jboss.tools.smooks.edimap.wizard.EDIMappingConfigFileWizard"
+ icon="icons/sample.gif"
+
id="org.jboss.tools.smooks.configuration.wizards.NewEDIMappingConfigurationFileWizard"
+ name="EDI Message Mapping Configuration File">
+ </wizard>
</extension>
<extension
@@ -120,6 +127,10 @@
exactMatch="true"
id="org.jboss.tools.smooks.ui.smooks.contentType">
</contentType>
+ <contentType
+ exactMatch="true"
+ id="org.jboss.tools.smooks.ui.edimap.contentType">
+ </contentType>
</rules>
</include>
</validator>
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ModelPanelCreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ModelPanelCreator.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ModelPanelCreator.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -52,7 +52,8 @@
}
/**
- * @param propertySource the propertySource to set
+ * @param propertySource
+ * the propertySource to set
*/
public void setPropertySource(IItemPropertySource propertySource) {
this.propertySource = propertySource;
@@ -66,16 +67,17 @@
}
/**
- * @param model the model to set
+ * @param model
+ * the model to set
*/
public void setModel(EObject model) {
this.model = model;
}
private IItemPropertySource propertySource;
-
- public ModelPanelCreator(){
-
+
+ public ModelPanelCreator() {
+
}
public ModelPanelCreator(EObject model, IItemPropertySource propertySource) {
@@ -87,13 +89,14 @@
currentPropertyUIMap.clear();
}
- public void createModelPanel(FormToolkit formToolkit, Composite detailsComposite,
ISmooksModelProvider provider,
- IEditorPart part) {
- this.createModelPanel(model, formToolkit, detailsComposite, propertySource, provider,
part);
+ public Map<Object, Object> createModelPanel(FormToolkit formToolkit, Composite
detailsComposite,
+ ISmooksModelProvider provider, IEditorPart part) {
+ return this.createModelPanel(model, formToolkit, detailsComposite, propertySource,
provider, part);
}
- public void createModelPanel(final EObject model, FormToolkit formToolkit, Composite
detailsComposite,
- IItemPropertySource itemPropertySource, ISmooksModelProvider provider, IEditorPart
part) {
+ public Map<Object, Object> createModelPanel(final EObject model, FormToolkit
formToolkit,
+ Composite detailsComposite, IItemPropertySource itemPropertySource,
ISmooksModelProvider provider,
+ IEditorPart part) {
cleanCurrentPropertyUIMap();
IPropertyUICreator creator =
PropertyUICreatorManager.getInstance().getPropertyUICreator(model);
List<IItemPropertyDescriptor> propertyDes =
itemPropertySource.getPropertyDescriptors(model);
@@ -155,8 +158,13 @@
// propertyMainComposite.layout();
markPropertyUI(provider.getDiagnosticList(), model);
+
+ Map<Object, Object> map = new HashMap<Object, Object>();
+ // map.putAll(currentPropertyUIMap);
+
+ return map;
}
-
+
public void markPropertyUI(List<Diagnostic> diagnosticList) {
markPropertyUI(diagnosticList, model);
}
@@ -210,7 +218,7 @@
hasCreated = true;
}
if (typeClazz.getInstanceClass() == Integer.class || typeClazz.getInstanceClass() ==
int.class) {
- editPart = createStringFieldEditor(model, detailsComposite, feature, formToolkit,
+ editPart = createIntegerFieldEditor(model, detailsComposite, feature, formToolkit,
itemPropertyDescriptor);
hasCreated = true;
}
@@ -224,6 +232,12 @@
return editPart;
}
+ protected AttributeFieldEditPart createIntegerFieldEditor(Object model, final Composite
propertyComposite,
+ EAttribute feature, FormToolkit formToolKit, final IItemPropertyDescriptor
itemPropertyDescriptor) {
+ return SmooksUIUtils.createNumberFieldEditor(null, propertyComposite, formToolKit,
itemPropertyDescriptor,
+ model);
+ }
+
protected AttributeFieldEditPart createEnumFieldEditor(FormToolkit formToolkit, final
EObject model,
Composite propertyComposite, EAttribute feature, final EEnum typeClass, FormToolkit
formToolKit,
final IItemPropertyDescriptor itemPropertyDescriptor) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -27,17 +27,12 @@
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
-import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Spinner;
import org.eclipse.ui.forms.IDetailsPage;
import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;
@@ -91,7 +86,7 @@
public void createContents(Composite parent) {
parent.setLayout(new FillLayout());
- section = formToolkit.createSection(parent, Section.TITLE_BAR|Section.DESCRIPTION);
+ section = formToolkit.createSection(parent, Section.TITLE_BAR | Section.DESCRIPTION);
Composite client = formToolkit.createComposite(section);
section.setLayout(new FillLayout());
@@ -119,12 +114,14 @@
IPropertyUICreator creator =
PropertyUICreatorManager.getInstance().getPropertyUICreator(getModel());
List<IItemPropertyDescriptor> propertyDes =
itemPropertySource.getPropertyDescriptors(getModel());
if (creator != null) {
- List<AttributeFieldEditPart> list =
creator.createExtendUIOnTop((AdapterFactoryEditingDomain) formEditor
- .getEditingDomain(), formToolkit, detailsComposite, getModel(),
getFormEditor(),getFormEditor());
+ List<AttributeFieldEditPart> list = creator.createExtendUIOnTop(
+ (AdapterFactoryEditingDomain) formEditor.getEditingDomain(), formToolkit,
detailsComposite,
+ getModel(), getFormEditor(), getFormEditor());
if (list != null) {
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
AttributeFieldEditPart attributeFieldEditPart = (AttributeFieldEditPart)
iterator.next();
- if(attributeFieldEditPart == null) continue;
+ if (attributeFieldEditPart == null)
+ continue;
Object attribute = attributeFieldEditPart.getAttribute();
if (attribute != null && attributeFieldEditPart != null) {
currentPropertyUIMap.put(attribute, attributeFieldEditPart);
@@ -138,7 +135,7 @@
EAttribute attribute = (EAttribute) pd.getFeature(getModel());
if (attribute.isRequired()) {
AttributeFieldEditPart editPart = createAttributeUI(detailsComposite, pd, creator);
- if (editPart != null && attribute != null) {
+ if (editPart != null && attribute != null) {
currentPropertyUIMap.put(attribute, editPart);
}
}
@@ -154,12 +151,14 @@
}
}
if (creator != null) {
- List<AttributeFieldEditPart> list =
creator.createExtendUIOnBottom((AdapterFactoryEditingDomain) formEditor
- .getEditingDomain(), formToolkit, detailsComposite, getModel(),
getFormEditor(),getFormEditor());
+ List<AttributeFieldEditPart> list = creator.createExtendUIOnBottom(
+ (AdapterFactoryEditingDomain) formEditor.getEditingDomain(), formToolkit,
detailsComposite,
+ getModel(), getFormEditor(), getFormEditor());
if (list != null) {
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
AttributeFieldEditPart attributeFieldEditPart = (AttributeFieldEditPart)
iterator.next();
- if(attributeFieldEditPart == null) continue;
+ if (attributeFieldEditPart == null)
+ continue;
Object attribute = attributeFieldEditPart.getAttribute();
if (attribute != null && attributeFieldEditPart != null) {
currentPropertyUIMap.put(attribute, attributeFieldEditPart);
@@ -249,7 +248,7 @@
return null;
}
editPart = creator.createPropertyUI(formToolkit, detailsComposite,
itemPropertyDescriptor, getModel(),
- feature, getFormEditor(),getFormEditor());
+ feature, getFormEditor(), getFormEditor());
if (editPart != null) {
createDefault = false;
}
@@ -271,7 +270,7 @@
hasCreated = true;
}
if (typeClazz.getInstanceClass() == Integer.class || typeClazz.getInstanceClass() ==
int.class) {
- editPart = createStringFieldEditor(detailsComposite, feature, formToolkit,
itemPropertyDescriptor);
+ editPart = createIntegerFieldEditor(detailsComposite, feature, formToolkit,
itemPropertyDescriptor);
hasCreated = true;
}
if (!hasCreated) {
@@ -356,36 +355,11 @@
getModel(), false, false, null);
}
- protected void createIntegerFieldEditor(final Composite propertyComposite, EAttribute
feature,
+ protected AttributeFieldEditPart createIntegerFieldEditor(final Composite
propertyComposite, EAttribute feature,
FormToolkit formToolKit, final IItemPropertyDescriptor itemPropertyDescriptor) {
- SmooksUIUtils.createFieldEditorLabel(null, propertyComposite, formToolKit,
itemPropertyDescriptor, getModel(),
- false);
- final Spinner spinner = new Spinner(propertyComposite, SWT.BORDER);
- Object value = itemPropertyDescriptor.getPropertyValue(getModel());
- if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
- if (editValue != null && editValue instanceof Integer)
- spinner.setSelection((Integer) editValue);
- }
- spinner.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Object value = itemPropertyDescriptor.getPropertyValue(getModel());
- if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
- if (editValue != null) {
- if (!editValue.equals(spinner.getSelection())) {
- itemPropertyDescriptor.setPropertyValue(getModel(), spinner.getSelection());
- }
- } else {
- itemPropertyDescriptor.setPropertyValue(getModel(), spinner.getSelection());
- }
- } else {
- itemPropertyDescriptor.setPropertyValue(getModel(), spinner.getSelection());
- }
- }
- });
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- spinner.setLayoutData(gd);
+
+ return SmooksUIUtils.createNumberFieldEditor(null, propertyComposite, formToolKit,
itemPropertyDescriptor,
+ getModel());
}
/*
@@ -477,7 +451,8 @@
text = ((EObject) model).eClass().getName();
}
section.setText(text);
-// section.setDescription("Details of " + text + ". Required fields are
denoted by \"*\".");
+ // section.setDescription("Details of " + text +
+ // ". Required fields are denoted by \"*\".");
section.layout();
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/FieldUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/FieldUICreator.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/FieldUICreator.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -46,5 +46,17 @@
return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor,part);
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.PropertyUICreator#ignoreProperty(org.eclipse.emf.ecore.EAttribute)
+ */
+ @Override
+ public boolean ignoreProperty(EAttribute feature) {
+ if(feature == MEdiPackage.Literals.MAPPING_NODE__XMLTAG){
+ return true;
+ }
+ return super.ignoreProperty(feature);
+ }
+
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentUICreator.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -35,9 +35,9 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public AttributeFieldEditPart createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
- ISmooksModelProvider formEditor, IEditorPart part) {
-
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ ISmooksModelProvider formEditor, IEditorPart part) {
+
if (feature == MEdiPackage.eINSTANCE.getSegment_MaxOccurs()) {
}
if (feature == MEdiPackage.eINSTANCE.getSegment_MinOccurs()) {
@@ -47,8 +47,25 @@
if (feature == MEdiPackage.eINSTANCE.getSegment_Truncatable()) {
}
- return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
- formEditor,part);
+ return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor, part);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.configuration.editors.PropertyUICreator#ignoreProperty
+ * (org.eclipse.emf.ecore.EAttribute)
+ */
+ @Override
+ public boolean ignoreProperty(EAttribute feature) {
+ if (feature == MEdiPackage.Literals.MAPPING_NODE__XMLTAG) {
+ return true;
+ }
+ if (feature == MEdiPackage.Literals.SEGMENT__SEGCODE) {
+ return true;
+ }
+ return super.ignoreProperty(feature);
+ }
+
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentsUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentsUICreator.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SegmentsUICreator.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -18,6 +18,7 @@
import org.jboss.tools.smooks.configuration.editors.AttributeFieldEditPart;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.model.medi.MEdiPackage;
/**
* @author Dart Peng (dpeng(a)redhat.com) Date Apr 10, 2009
@@ -41,4 +42,14 @@
formEditor,part);
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.PropertyUICreator#ignoreProperty(org.eclipse.emf.ecore.EAttribute)
+ */
+ @Override
+ public boolean ignoreProperty(EAttribute feature) {
+ if(feature == MEdiPackage.Literals.MAPPING_NODE__XMLTAG){
+ return true;
+ }
+ return super.ignoreProperty(feature);
+ }
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SubComponentUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SubComponentUICreator.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/SubComponentUICreator.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -44,5 +44,17 @@
return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor,part);
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.PropertyUICreator#ignoreProperty(org.eclipse.emf.ecore.EAttribute)
+ */
+ @Override
+ public boolean ignoreProperty(EAttribute feature) {
+ if(feature == MEdiPackage.Literals.MAPPING_NODE__XMLTAG){
+ return true;
+ }
+ return super.ignoreProperty(feature);
+ }
+
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -30,7 +30,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.draw2d.IFigure;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
@@ -121,7 +120,6 @@
import
org.jboss.tools.smooks.configuration.editors.javabean.JavaPropertiesSelectionDialog;
import org.jboss.tools.smooks.core.SmooksCoreActivator;
import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart;
-import org.jboss.tools.smooks.gef.tree.figures.TreeNodeFigure;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
import org.jboss.tools.smooks.model.freemarker.BindTo;
import org.jboss.tools.smooks.model.freemarker.Freemarker;
@@ -475,6 +473,103 @@
linkLabel, openFile, height, listener, valueType, openEditorAction, false);
}
+ public static AttributeFieldEditPart createNumberFieldEditor(String label, final
Composite parent,
+ FormToolkit toolkit, final IItemPropertyDescriptor itemPropertyDescriptor, Object
model) {
+ AttributeFieldEditPart fieldEditPart = new AttributeFieldEditPart();
+ GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+ Section section = null;
+ Composite textContainer = parent;
+ final Object fm = model;
+ if (label == null && itemPropertyDescriptor != null) {
+ label = itemPropertyDescriptor.getDisplayName(model);
+ EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
+ if (feature.isRequired()) {
+ label = label + "*";
+ }
+ }
+ FieldMarkerWrapper warpper = createFieldEditorLabel(label, parent, toolkit,
itemPropertyDescriptor, model,
+ false);
+ fieldEditPart.setFieldMarker(warpper.getMarker());
+
+ Object editValue = getEditValue(itemPropertyDescriptor, model);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+
+ int textType = SWT.FLAT;
+ if (isLinuxOS()) {
+ textType = SWT.BORDER;
+ }
+ Composite tcom = toolkit.createComposite(textContainer);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.horizontalSpacing = 0;
+ tcom.setLayout(layout);
+
+ FieldMarkerComposite notificationComposite = new FieldMarkerComposite(tcom, SWT.NONE);
+ gd = new GridData();
+ gd.heightHint = 8;
+ gd.widthHint = 8;
+ gd.horizontalAlignment = GridData.BEGINNING;
+ gd.verticalAlignment = GridData.BEGINNING;
+ notificationComposite.setLayoutData(gd);
+ fieldEditPart.setFieldMarker(notificationComposite);
+
+ final Text valueText = toolkit.createText(tcom, "", textType);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ valueText.setLayoutData(gd);
+
+ tcom.setLayoutData(gd);
+
+ toolkit.paintBordersFor(textContainer);
+
+ boolean valueIsSet = true;
+ if (model != null && model instanceof EObject && itemPropertyDescriptor
!= null) {
+ valueIsSet = ((EObject) model).eIsSet((EAttribute)
itemPropertyDescriptor.getFeature(model));
+ }
+ if (editValue != null && valueIsSet && editValue instanceof Integer) {
+ valueText.setText(editValue.toString());
+ }
+ if (itemPropertyDescriptor != null) {
+ valueText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ Object editValue = getEditValue(itemPropertyDescriptor, fm);
+ if (editValue != null) {
+ String vt = valueText.getText();
+ Integer newValue = null;
+ try {
+ newValue = Integer.parseInt(vt);
+ } catch (Throwable t) {
+ return;
+ }
+ if (vt == null || vt.length() == 0) {
+ itemPropertyDescriptor.setPropertyValue(fm, null);
+ } else {
+ if (!editValue.equals(newValue)) {
+ itemPropertyDescriptor.setPropertyValue(fm, newValue);
+ }
+ }
+ } else {
+ String vt = valueText.getText();
+ Integer newValue = null;
+ try {
+ newValue = Integer.parseInt(vt);
+ } catch (Throwable t) {
+ return;
+ }
+ itemPropertyDescriptor.setPropertyValue(fm, newValue);
+ }
+
+ }
+ });
+ }
+ if (section != null)
+ section.layout();
+ fieldEditPart.setContentControl(valueText);
+ return fieldEditPart;
+ }
+
public static AttributeFieldEditPart createStringFieldEditor(String label, final
Composite parent,
EditingDomain editingdomain, FormToolkit toolkit, final IItemPropertyDescriptor
itemPropertyDescriptor,
Object model, boolean multiText, boolean linkLabel, boolean openFile, int height,
@@ -713,6 +808,7 @@
public void modifyText(ModifyEvent e) {
Object editValue = getEditValue(itemPropertyDescriptor, fm);
if (editValue != null) {
+ String vt = valueText.getText();
if (valueText.getText() == null || valueText.getText().length() == 0) {
itemPropertyDescriptor.setPropertyValue(fm, null);
} else {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/actions/RenameXmlTagNameCommand.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/actions/RenameXmlTagNameCommand.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/actions/RenameXmlTagNameCommand.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -29,7 +29,7 @@
*/
@Override
protected void refreshEditPart() {
- editPart.refresh();
+// editPart.refresh();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIFileParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIFileParser.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIFileParser.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -24,6 +24,7 @@
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
+import org.jboss.tools.smooks.edimap.models.EDIDataContainerModel;
/**
* @author Dart dpeng(a)redhat.com
@@ -60,7 +61,7 @@
String[] fields = string.split("\\" + new String(new char[] { field }));
TagObject tag = null;
if (fields.length != 0) {
- tag = new TagObject();
+ tag = new EDIDataContainerModel();
if (names.indexOf(fields[0]) == -1) {
tag.setName(fields[0].trim());
names.add(tag.getName());
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -11,18 +11,33 @@
package org.jboss.tools.smooks.edimap.editor;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.EventObject;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandWrapper;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
@@ -43,7 +58,9 @@
import org.eclipse.gef.ui.actions.UpdateAction;
import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -60,17 +77,21 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.jboss.tools.smooks.configuration.editors.AttributeFieldEditPart;
import org.jboss.tools.smooks.configuration.editors.ModelPanelCreator;
+import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
@@ -101,6 +122,12 @@
import org.jboss.tools.smooks.model.medi.Segment;
import org.jboss.tools.smooks.model.medi.Segments;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+import org.milyn.Smooks;
+import org.milyn.SmooksUtil;
+import org.milyn.cdr.SmooksResourceConfiguration;
+import org.milyn.smooks.edi.SmooksEDIReader;
+import org.milyn.xml.XmlUtil;
+import org.w3c.dom.Document;
/**
* @author Dart
@@ -218,9 +245,9 @@
DocumentRoot root = (DocumentRoot) modelProvider.getSmooksModel();
Segments segments = root.getEdimap().getSegments();
- EDIMappingNodeContainerGraphModel container = new
EDIMappingNodeContainerGraphModel(segments, new AdapterFactoryContentProvider(
- editingDomain.getAdapterFactory()),
- new EDIGraphicalTreeLabelProvider(editingDomain.getAdapterFactory()));
+ EDIMappingNodeContainerGraphModel container = new
EDIMappingNodeContainerGraphModel(segments,
+ new AdapterFactoryContentProvider(editingDomain.getAdapterFactory()),
+ new EDIGraphicalTreeLabelProvider(editingDomain.getAdapterFactory()),
modelProvider);
container.setHeaderVisable(true);
graphicalRootModel.addTreeNode(container);
@@ -329,8 +356,7 @@
protected void configureGraphicalViewer() {
createGEFActions();
- getGraphicalViewer().getControl().setBackground(
- getManagedForm().getToolkit().getColors().getColor(IFormColors.H_HOVER_LIGHT));
+ getGraphicalViewer().getControl().setBackground(ColorConstants.button);
getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart());
getGraphicalViewer().setEditPartFactory(new EDIEditPartFactory());
@@ -369,13 +395,28 @@
if (delimitersCreator != null) {
IItemPropertySource itemPropertySource = (IItemPropertySource)
editingDomain.getAdapterFactory().adapt(
delimiters, IItemPropertySource.class);
- delimitersCreator.createModelPanel(delimiters, toolkit, delimitersComposite,
itemPropertySource,
- modelProvider, getEditor());
+ Map<Object, Object> fieldEditorMap =
delimitersCreator.createModelPanel(delimiters, toolkit,
+ delimitersComposite, itemPropertySource, modelProvider, getEditor());
+ handleDelimiterFieldEditor(fieldEditorMap);
}
delimitersComposite.getParent().layout();
initGraphicalModel();
}
+ private void handleDelimiterFieldEditor(Map<Object, Object> fieldEditorMap) {
+ // Iterator<Object> keyIterator = fieldEditorMap.keySet().iterator();
+ // while (keyIterator.hasNext()) {
+ // Object key = keyIterator.next();
+ // AttributeFieldEditPart editPart = (AttributeFieldEditPart)
+ // fieldEditorMap.get(key);
+ // Control control = editPart.getContentControl();
+ // if (control instanceof Text) {
+ // ((Text) control).addModifyListener(new DelimiterModifyListener());
+ //
+ // }
+ // }
+ }
+
private void removeEDIGraphModel() {
List<TreeNodeModel> children = this.graphicalRootModel.getChildren();
List<TreeNodeModel> temp = new ArrayList<TreeNodeModel>(children);
@@ -490,6 +531,8 @@
description, IItemPropertySource.class);
descriptionCreator = new ModelPanelCreator(description, propertySource2);
+
+ handleCommandStack(editingDomain.getCommandStack());
}
}
@@ -501,6 +544,9 @@
this.description = root.getEdimap().getDescription();
this.segments = root.getEdimap().getSegments();
+ if(segments.getXmltag() == null){
+ segments.setXmltag("root");
+ }
editingDomain = (AdapterFactoryEditingDomain) modelProvider.getEditingDomain();
@@ -568,16 +614,65 @@
FillLayout flayout = new FillLayout();
descriptionSection.setLayout(flayout);
- descriptorComposite = toolkit.createComposite(descriptionSection, SWT.NONE);
+ Composite desciptorContainer = toolkit.createComposite(descriptionSection);
+ GridLayout dgl = new GridLayout();
+ dgl.marginHeight = 0;
+ dgl.marginWidth = 0;
+ desciptorContainer.setLayout(dgl);
+ descriptionSection.setClient(desciptorContainer);
+
+ descriptorComposite = toolkit.createComposite(desciptorContainer, SWT.NONE);
GridLayout gl = new GridLayout();
gl.numColumns = 2;
descriptorComposite.setLayout(gl);
- descriptionSection.setClient(descriptorComposite);
+ gd = new GridData(GridData.FILL_BOTH);
+ descriptorComposite.setLayoutData(gd);
if (descriptionCreator != null) {
descriptionCreator.createModelPanel(toolkit, descriptorComposite, modelProvider,
getEditor());
}
+ Hyperlink showTransformResultLink = toolkit.createHyperlink(desciptorContainer,
"Test EDI transform", SWT.NONE);
+ showTransformResultLink.setVisible(false);
+ showTransformResultLink.addHyperlinkListener(new IHyperlinkListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(
+ * org.eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ public void linkActivated(HyperlinkEvent e) {
+ testEDITransform();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org
+ * .eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ public void linkEntered(HyperlinkEvent e) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org
+ * .eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ public void linkExited(HyperlinkEvent e) {
+
+ }
+
+ });
+ gd = new GridData();
+ showTransformResultLink.setLayoutData(gd);
+
Section delimiterSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR |
Section.DESCRIPTION);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = GridData.BEGINNING;
@@ -603,7 +698,9 @@
ediFileText.addModifyListener(this);
if (delimitersCreator != null) {
- delimitersCreator.createModelPanel(toolkit, delimitersComposite, modelProvider,
getEditor());
+ Map<Object, Object> editPartMap = delimitersCreator.createModelPanel(toolkit,
delimitersComposite,
+ modelProvider, getEditor());
+ handleDelimiterFieldEditor(editPartMap);
}
// Section testSection = toolkit.createSection(form.getBody(),
@@ -664,8 +761,52 @@
mappingModelPropertiesComposite.setLayout(mgl);
sashForm.setWeights(new int[] { 10, 3 });
+
}
+ 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();
+ 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 SetCommand || rawCommand instanceof AddCommand
+ || rawCommand instanceof DeleteCommand) {
+ refershRecentAffectedModel(rawCommand, mostRecentCommand.getAffectedObjects());
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+
+ private void refershRecentAffectedModel(Command command, Collection<?> models) {
+ for (Iterator<?> iterator = models.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object == this.delimiters) {
+ rebuildEDIGraph();
+ continue;
+ }
+ TreeNodeModel node = findEDIGraphicalModel(object);
+ if (node == null)
+ continue;
+ if (command instanceof SetCommand) {
+ node.fireVisualChanged();
+ }
+ if (command instanceof AddCommand || command instanceof DeleteCommand) {
+ node.fireChildrenChanged();
+ node.fireConnectionChanged();
+ }
+ }
+ }
+
private void createEDIDataGraphModel() {
if (ediFilePath != null) {
try {
@@ -727,21 +868,31 @@
private void disconnectSegement(List<Segment> segmentList) {
for (Iterator<?> iterator = segmentList.iterator(); iterator.hasNext();) {
Segment segment = (Segment) iterator.next();
- TreeNodeModel segmentGraphicalModel = findSegmentGraphicalModel(segment);
+ TreeNodeModel segmentGraphicalModel = findEDIGraphicalModel(segment);
+ if (segmentGraphicalModel == null)
+ continue;
List<TreeNodeConnection> sourceConnections =
segmentGraphicalModel.getSourceConnections();
List<TreeNodeConnection> targetConnections =
segmentGraphicalModel.getTargetConnections();
List<TreeNodeConnection> sourceConnectionsTemp = new
ArrayList<TreeNodeConnection>(sourceConnections);
List<TreeNodeConnection> targetConnectionsTemp = new
ArrayList<TreeNodeConnection>(targetConnections);
for (Iterator<?> iterator2 = targetConnectionsTemp.iterator();
iterator2.hasNext();) {
TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
- treeNodeConnection.disconnect();
+ // don't earse the segcode
+ treeNodeConnection.getSourceNode().getSourceConnections().remove(treeNodeConnection);
+ treeNodeConnection.getSourceNode().fireConnectionChanged();
+ treeNodeConnection.getTargetNode().getTargetConnections().remove(treeNodeConnection);
+ treeNodeConnection.getTargetNode().fireConnectionChanged();
+ // treeNodeConnection.disconnect();
}
targetConnectionsTemp.clear();
targetConnectionsTemp = null;
for (Iterator<?> iterator2 = sourceConnectionsTemp.iterator();
iterator2.hasNext();) {
TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
- treeNodeConnection.disconnect();
+ treeNodeConnection.getSourceNode().getSourceConnections().remove(treeNodeConnection);
+ treeNodeConnection.getSourceNode().fireConnectionChanged();
+ treeNodeConnection.getTargetNode().getTargetConnections().remove(treeNodeConnection);
+ treeNodeConnection.getTargetNode().fireConnectionChanged();
}
sourceConnectionsTemp.clear();
sourceConnectionsTemp = null;
@@ -769,12 +920,12 @@
List<TreeNodeModel> sourceLinkedModel = new ArrayList<TreeNodeModel>();
for (Iterator<?> iterator = segmentList.iterator(); iterator.hasNext();) {
Segment segment = (Segment) iterator.next();
- TreeNodeModel segmentGraphicalModel = findSegmentGraphicalModel(segment);
+ TreeNodeModel segmentGraphicalModel = findEDIGraphicalModel(segment);
String code = segment.getSegcode();
TreeNodeModel model = findEDIDataGraphicalModel(code);
- if (segmentGraphicalModel == null || model == null)
- continue;
- new TreeNodeConnection(segmentGraphicalModel, model).connect();
+ if (segmentGraphicalModel != null && model != null) {
+ new TreeNodeConnection(segmentGraphicalModel, model).connect();
+ }
sourceLinkedModel.add(segmentGraphicalModel);
List<TreeNodeModel> linkedModel = linkNode(segment.getSegment());
if (linkedModel != null) {
@@ -784,28 +935,54 @@
return sourceLinkedModel;
}
+ // private TreeNodeModel findEDIGraphModel(Object model){
+ // if (graphicalRootModel != null) {
+ // List<TreeNodeModel> treeNodeList = graphicalRootModel.getChildren();
+ // return findEDIGraphicalModel(model, treeNodeList);
+ // }
+ // return null;
+ // }
+ //
+ // private TreeNodeModel findEDIGraphicalModel(Object model,
+ // List<TreeNodeModel> treeNodeList) {
+ // for (Iterator<?> iterator = treeNodeList.iterator(); iterator.hasNext();)
+ // {
+ // TreeNodeModel treeNodeModel = (TreeNodeModel) iterator.next();
+ // Object model = treeNodeModel.getData();
+ // if (model == segment) {
+ // return treeNodeModel;
+ // }
+ // TreeNodeModel m = findSegmentGraphicalModel(segment,
+ // treeNodeModel.getChildren());
+ // if (m != null) {
+ // return m;
+ // }
+ // }
+ // return null;
+ // }
+
/**
* it's dangerous , the method is dangerous
*
- * @param segment
+ * @param model
* @return
*/
- private TreeNodeModel findSegmentGraphicalModel(Segment segment) {
+ private TreeNodeModel findEDIGraphicalModel(Object model) {
if (graphicalRootModel != null) {
List<TreeNodeModel> treeNodeList = graphicalRootModel.getChildren();
- return findSegmentGraphicalModel(segment, treeNodeList);
+ return findEDIGraphicalModel(model, treeNodeList);
}
return null;
}
- private TreeNodeModel findSegmentGraphicalModel(Segment segment,
List<TreeNodeModel> treeNodeList) {
+ private TreeNodeModel findEDIGraphicalModel(Object model, List<TreeNodeModel>
treeNodeList) {
for (Iterator<?> iterator = treeNodeList.iterator(); iterator.hasNext();) {
TreeNodeModel treeNodeModel = (TreeNodeModel) iterator.next();
- Object model = treeNodeModel.getData();
- if (model == segment) {
+ Object data = treeNodeModel.getData();
+ if (data == model) {
return treeNodeModel;
}
- TreeNodeModel m = findSegmentGraphicalModel(segment, treeNodeModel.getChildren());
+ TreeNodeModel m = findEDIGraphicalModel(model, treeNodeModel.getChildren());
if (m != null) {
return m;
}
@@ -814,6 +991,8 @@
}
private TreeNodeModel findEDIDataGraphicalModel(String code) {
+ if (code == null)
+ return null;
if (graphicalRootModel != null) {
List<TreeNodeModel> treeNodeList = graphicalRootModel.getChildren();
for (Iterator<?> iterator = treeNodeList.iterator(); iterator.hasNext();) {
@@ -866,6 +1045,7 @@
public void selectionChanged(SelectionChangedEvent event) {
if (event.getSource() == getGraphicalViewer()) {
+ initEDIModels();
disposeMappingModelPropertiesCompoisiteControls();
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() > 1)
@@ -881,6 +1061,8 @@
if ((model instanceof EObject)) {
IItemPropertySource itemPropertySource = (IItemPropertySource)
editingDomain.getAdapterFactory()
.adapt(model, IItemPropertySource.class);
+ segmentsCreator.setModel((EObject) model);
+ segmentsCreator.setPropertySource(itemPropertySource);
segmentsCreator.createModelPanel((EObject) model,
this.getManagedForm().getToolkit(),
mappingModelPropertiesComposite, itemPropertySource, modelProvider, getEditor());
mappingModelPropertiesComposite.getParent().layout();
@@ -890,6 +1072,75 @@
}
}
+ protected void testEDITransform() {
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ if (this.getEditor().isDirty()) {
+ MessageDialog.openInformation(getEditorSite().getShell(), "Info",
+ "The configuration file should be saved");
+ return;
+ }
+ IFileEditorInput input = (IFileEditorInput) getEditorInput();
+ IFile file = input.getFile();
+ String path = file.getLocation().toOSString();
+ File ediFile = new File(SmooksUIUtils.parseFilePath(ediFilePath));
+
+ if (ediFile == null || !ediFile.exists()) {
+ MessageDialog.openError(getEditorSite().getShell(), "Transform Error",
"Can't the find the EDI file : "
+ + ediFilePath);
+ return;
+ }
+
+ if (file == null || !file.exists()) {
+ MessageDialog.openError(getEditorSite().getShell(), "Transform Error",
+ "Can't find the EDI mapping configuration file : " + path);
+ return;
+ }
+
+ IPath path1 = file.getFullPath().removeFirstSegments(1);
+
+ ProjectClassLoader classLoader = new
ProjectClassLoader(JavaCore.create(file.getProject()));
+
+ Thread.currentThread().setContextClassLoader(classLoader);
+ Smooks smooks = new Smooks();
+
+ SmooksResourceConfiguration readerConfig = new
SmooksResourceConfiguration("org.xml.sax.driver",
+ SmooksEDIReader.class.getName());
+
+ readerConfig.setParameter("mapping-model", path1.toString());
+ readerConfig.setParameter("encoding", "UTF-8");
+
+ SmooksUtil.registerResource(readerConfig, smooks);
+
+ // Use a DOM result to capture the message model for the supplied
+ // CSV
+ // message...
+ DOMResult domResult = new DOMResult();
+
+ // Filter the message through Smooks and capture the result as a DOM
+ // in
+ // the domResult instance...
+ smooks.filter(new StreamSource(new FileInputStream(ediFile)), domResult);
+
+ // Get the Document object from the domResult. This is the message
+ // model!!!...
+ Document model = (Document) domResult.getNode();
+
+ // So using the model Document, you can construct a tree structure
+ // for
+ // the editor.
+
+ // We'll just print out the model DOM here so you can see it....
+ StringWriter modelWriter = new StringWriter();
+ XmlUtil.serialize(model, true, modelWriter);
+ System.out.println(modelWriter);
+ } catch (Throwable t) {
+ SmooksUIUtils.showErrorDialog(getEditorSite().getShell(),
SmooksUIUtils.createErrorStatus(t));
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ }
+
public void modifyText(ModifyEvent e) {
Text ediFileText = (Text) e.getSource();
ediFilePath = ediFileText.getText();
@@ -905,7 +1156,11 @@
}
SmooksUIUtils.recordInputDataInfomation(inputType1,
modelProvider.getSmooksGraphicsExt(),
SmooksModelUtils.INPUT_TYPE_EDI, ediFilePath, null);
+ rebuildEDIGraph();
+ }
+ private void rebuildEDIGraph() {
+ SmooksGraphicsExtType ext = modelProvider.getSmooksGraphicsExt();
disconnectSegements();
removeEDIGraphModel();
createEDIDataGraphModel();
@@ -913,4 +1168,20 @@
List<TreeNodeModel> sourceLinkedModel = this.createLinkModel();
expandSegmentNode(sourceLinkedModel);
}
+
+ private class DelimiterModifyListener implements ModifyListener {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.
+ * events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ rebuildEDIGraph();
+
+ }
+
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/AbstractEDIMappingEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/AbstractEDIMappingEditPart.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/AbstractEDIMappingEditPart.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -106,11 +106,6 @@
}
}
return null;
- // RenameActivityCommand cmd = new RenameActivityCommand();
- // cmd.setSource((Activity)getHost().getModel());
- // cmd.setOldName(((Activity)getHost().getModel()).getName());
- // cmd.setName((String)request.getCellEditor().getValue());
- // return cmd;
}
/*
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIDataContainerModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIDataContainerModel.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIDataContainerModel.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.edimap.models;
+
+import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDIDataContainerModel extends TagObject {
+ public String getSegCode() {
+ return getName();
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIDataContainerModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeContainerGraphModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeContainerGraphModel.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeContainerGraphModel.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -1,5 +1,6 @@
package org.jboss.tools.smooks.edimap.models;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
@@ -7,9 +8,12 @@
public class EDIMappingNodeContainerGraphModel extends TreeContainerModel {
- public EDIMappingNodeContainerGraphModel(Object data, ITreeContentProvider
contentProvider, ILabelProvider labelProvider) {
+ private IEditingDomainProvider domainProvider;
+
+ public EDIMappingNodeContainerGraphModel(Object data, ITreeContentProvider
contentProvider,
+ ILabelProvider labelProvider, IEditingDomainProvider domainProvider) {
super(data, contentProvider, labelProvider);
- // TODO Auto-generated constructor stub
+ this.domainProvider = domainProvider;
}
/*
@@ -24,7 +28,7 @@
protected TreeNodeModel createChildModel(Object model, ITreeContentProvider
contentProvider,
ILabelProvider labelProvider) {
// TODO Auto-generated method stub
- return new EDIMappingNodeGraphModel(model, contentProvider, labelProvider);
+ return new EDIMappingNodeGraphModel(model, contentProvider,
labelProvider,domainProvider);
}
/*
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -10,60 +10,169 @@
******************************************************************************/
package org.jboss.tools.smooks.edimap.models;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+import org.jboss.tools.smooks.model.medi.MEdiPackage;
import org.jboss.tools.smooks.model.medi.Segment;
/**
* @author Dart (dpeng(a)redhat.com)
- *
+ *
*/
public class EDIMappingNodeGraphModel extends TreeNodeModel {
- public EDIMappingNodeGraphModel(Object data, ITreeContentProvider contentProvider,
ILabelProvider labelProvider) {
+ IEditingDomainProvider domainProvider = null;
+
+ public EDIMappingNodeGraphModel(Object data, ITreeContentProvider contentProvider,
ILabelProvider labelProvider,
+ IEditingDomainProvider domainProvider) {
super(data, contentProvider, labelProvider);
+ this.domainProvider = domainProvider;
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#createChildModel(java.lang.Object,
org.eclipse.jface.viewers.ITreeContentProvider, org.eclipse.jface.viewers.ILabelProvider)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#createChildModel(
+ * java.lang.Object, org.eclipse.jface.viewers.ITreeContentProvider,
+ * org.eclipse.jface.viewers.ILabelProvider)
*/
@Override
protected TreeNodeModel createChildModel(Object model, ITreeContentProvider
contentProvider,
ILabelProvider labelProvider) {
- return new EDIMappingNodeGraphModel(model, contentProvider, labelProvider);
+ return new EDIMappingNodeGraphModel(model, contentProvider, labelProvider,
domainProvider);
}
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#canLinkWithSource(java.lang.Object)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#canLinkWithSource
+ * (java.lang.Object)
*/
@Override
public boolean canLinkWithSource(Object model) {
return false;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#addSourceConnection
+ * (org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection)
+ */
+ @Override
+ public void addSourceConnection(TreeNodeConnection connection) {
+ super.addSourceConnection(connection);
+ if (getData() instanceof Segment) {
+ TreeNodeModel targetNode = connection.getTargetNode();
+ if (targetNode != null && targetNode.getData() instanceof
EDIDataContainerModel) {
+ if (domainProvider != null) {
+ String segCode = ((EDIDataContainerModel) targetNode.getData()).getSegCode();
+ String sc = ((Segment) getData()).getSegcode();
+ if (sc != null && sc.equals(segCode)) {
+ return;
+ }
+ EditingDomain domain = domainProvider.getEditingDomain();
+ if (domain != null) {
+ Command command = SetCommand.create(domain, getData(),
MEdiPackage.Literals.SEGMENT__SEGCODE,
+ segCode);
+ domain.getCommandStack().execute(command);
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#removeSourceConnection
+ * (org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection)
+ */
+ @Override
+ public void removeSourceConnection(TreeNodeConnection connection) {
+ super.removeSourceConnection(connection);
+ if (getData() instanceof Segment) {
+ String sc = ((Segment) getData()).getSegcode();
+ if (sc == null) {
+ return;
+ }
+ if (domainProvider != null) {
+ EditingDomain domain = domainProvider.getEditingDomain();
+ if (domain != null) {
+ Command command = SetCommand.create(domain, getData(),
MEdiPackage.Literals.SEGMENT__SEGCODE, null);
+ domain.getCommandStack().execute(command);
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#removeTargetConnection
+ * (org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection)
+ */
+ @Override
+ public void removeTargetConnection(TreeNodeConnection connection) {
+ // TODO Auto-generated method stub
+ super.removeTargetConnection(connection);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#addTargetConnection
+ * (org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection)
+ */
+ @Override
+ public void addTargetConnection(TreeNodeConnection connection) {
+ super.addTargetConnection(connection);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#isLinkable()
*/
@Override
public boolean isLinkable() {
Object nodeModel = getData();
- if(!(nodeModel instanceof Segment)){
+ if (!(nodeModel instanceof Segment)) {
return false;
+ }else{
+ if(!this.getSourceConnections().isEmpty()){
+ return false;
+ }
}
return super.isLinkable();
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#canLinkWithTarget(java.lang.Object)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#canLinkWithTarget
+ * (java.lang.Object)
*/
@Override
public boolean canLinkWithTarget(Object model) {
Object nodeModel = getData();
- if(!(nodeModel instanceof Segment)){
+ if (!(nodeModel instanceof Segment)) {
return false;
}
- if(model instanceof EDIDataContainerGraphModel){
+ if (model instanceof EDIDataContainerGraphModel) {
return true;
}
return false;
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileConfigPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileConfigPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileConfigPage.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -0,0 +1,490 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.edimap.wizard;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDIMappingConfigFileConfigPage extends WizardPage {
+
+ private String name;
+
+ private String version;
+
+ private String segments;
+
+ private String componentDelimiter;
+
+ private String subComponentDelimiter;
+
+ private String fieldDelimiter;
+
+ private String segmentDelimiter;
+
+ private String ediFilePath;
+
+ private String[] fileExtensionNames;
+
+ private ISelection selection;
+
+
+ public EDIMappingConfigFileConfigPage(String pageName, String title, ImageDescriptor
titleImage,ISelection selection) {
+ super(pageName, title, titleImage);
+ this.selection = selection;
+ this.setTitle("Config EDI Mapping File");
+ this.setDescription("Define the demiliters and other details of EDI mapping
file");
+ }
+
+ public EDIMappingConfigFileConfigPage(String pageName,ISelection selection) {
+ super(pageName);
+ this.selection = selection;
+ this.setTitle("Config EDI Mapping File");
+ this.setDescription("Define the demiliters and other details of EDI mapping
file");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ mainComposite.setLayoutData(gd);
+
+ GridLayout mgl = new GridLayout();
+ mainComposite.setLayout(mgl);
+ mgl.numColumns = 2;
+ mgl.verticalSpacing = 8;
+ mgl.horizontalSpacing = 5;
+
+ Label nameLabel = new Label(mainComposite, SWT.NONE);
+ nameLabel.setText("Name:");
+ final Text nameText = new Text(mainComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ nameText.setLayoutData(gd);
+ nameText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setName(nameText.getText());
+ }
+
+ });
+
+ Label versionLabel = new Label(mainComposite, SWT.NONE);
+ versionLabel.setText("Version:");
+ final Text versionText = new Text(mainComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ versionText.setLayoutData(gd);
+ versionText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setVersion(versionText.getText());
+ }
+
+ });
+
+ Label segmentsNameLabel = new Label(mainComposite, SWT.NONE);
+ segmentsNameLabel.setText("Root XMLTag Name:");
+ final Text segmentsNameText = new Text(mainComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ segmentsNameText.setLayoutData(gd);
+ segmentsNameText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setSegments(segmentsNameText.getText());
+ updatePageStatus();
+ }
+
+ });
+
+ Composite separator = new Composite(mainComposite,SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 10;
+
+ separator.setLayoutData(gd);
+
+ Group group = new Group(mainComposite,SWT.NONE);
+ group.setText("EDI File Delimiter");
+ GridLayout dgl = new GridLayout();
+ dgl.numColumns = 2;
+ dgl.verticalSpacing = 5;
+ dgl.horizontalSpacing = 5;
+ group.setLayout(dgl);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+
+ group.setLayoutData(gd);
+
+ Label segmentLabel = new Label(group, SWT.NONE);
+ segmentLabel.setText("Segment:");
+ final Text segmentText = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ segmentText.setLayoutData(gd);
+ segmentText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setSegmentDelimiter(segmentText.getText());
+ }
+
+ });
+
+ Label fieldLabel = new Label(group, SWT.NONE);
+ fieldLabel.setText("Field:");
+ final Text fieldText = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fieldText.setLayoutData(gd);
+
+ fieldText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setFieldDelimiter(fieldText.getText());
+ }
+
+ });
+
+ Label componentLabel = new Label(group, SWT.NONE);
+ componentLabel.setText("Component:");
+ final Text compoenentText = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ compoenentText.setLayoutData(gd);
+ compoenentText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setComponentDelimiter(compoenentText.getText());
+ }
+
+ });
+
+ Label subcomponentLabel = new Label(group, SWT.NONE);
+ subcomponentLabel.setText("SubComponent:");
+ final Text subcompoenentText = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ subcompoenentText.setLayoutData(gd);
+ subcompoenentText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setSubComponentDelimiter(subcompoenentText.getText());
+ }
+
+ });
+
+ Composite separator1= new Composite(mainComposite,SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 10;
+ separator1.setLayoutData(gd);
+
+ Label nfileLanel = new Label(mainComposite, SWT.NONE);
+ nfileLanel.setText("EDI Input Data File : "); //$NON-NLS-1$
+
+ final Text fileText = new Text(mainComposite,SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ fileText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ setEdiFilePath(fileText.getText());
+ }
+
+ });
+
+ Composite browseButtonComposite = new Composite(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ browseButtonComposite.setLayoutData(gd);
+
+ GridLayout bg = new GridLayout();
+ bg.numColumns = 2;
+ bg.marginHeight = 0;
+ bg.marginWidth = 0;
+ bg.makeColumnsEqualWidth = false;
+ browseButtonComposite.setLayout(bg);
+
+ final Button fileSystemBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ fileSystemBrowseButton.setText("Browse File System"); //$NON-NLS-1$
+
+ final Button workspaceBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ workspaceBrowseButton.setText("Browse WorkSpace"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.END;
+ workspaceBrowseButton.setLayoutData(gd);
+
+ gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.END;
+ fileSystemBrowseButton.setLayoutData(gd);
+
+ SelectionAdapter browseButtonSelectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Text relationT = null;
+ if (e.getSource() == fileSystemBrowseButton) {
+ relationT = fileText;
+ }
+ openFileSelection(relationT);
+ }
+ };
+ SelectionAdapter wbrowseButtonSelectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Text relationT = null;
+ if (e.getSource() == workspaceBrowseButton) {
+ relationT = fileText;
+ }
+ openWorkSpaceSelection(relationT);
+ }
+
+ };
+
+ fileSystemBrowseButton.addSelectionListener(browseButtonSelectionAdapter);
+ workspaceBrowseButton.addSelectionListener(wbrowseButtonSelectionAdapter);
+
+ setControl(mainComposite);
+
+ updatePageStatus();
+ }
+
+ protected void openFileSelection(Text relationText) {
+ FileDialog dialog = new FileDialog(this.getShell());
+ if (fileExtensionNames != null) {
+ String s = "";
+ for (int i = 0; i < fileExtensionNames.length; i++) {
+ String exname = fileExtensionNames[i];
+ s += "*." + exname + ";";
+ }
+ if (s.length() != 0) {
+ s = s.substring(0, s.length() - 1);
+ dialog.setFilterExtensions(new String[]{s,"*.*"});
+ }
+ }
+ String path = dialog.open();
+ if (path != null) {
+ path = processFileSystemFilePath(path);
+ relationText.setText(path);
+ }
+ }
+
+ protected String processWorkSpaceFilePath(IFile file) {
+// if (filePathProcessor != null) {
+// String s = filePathProcessor.processWorkBenchPath(file);
+// if (s != null) {
+// return s;
+// }
+// }
+ String s = file.getFullPath().toPortableString();
+ s = SmooksUIUtils.WORKSPACE_PRIX + s;
+ return s;
+ }
+
+ protected void openWorkSpaceSelection(Text relationT) {
+ Object[] obj = new Object[]{};
+
+ if(selection != null && selection instanceof IStructuredSelection){
+ obj = ((IStructuredSelection)selection).toArray();
+ }
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(),
+ "Select Files", "", false, obj, null); //$NON-NLS-1$
//$NON-NLS-2$
+ // dialog.setInitialSelections(selectedResources);
+ if (files.length > 0) {
+ IFile file = files[0];
+ String s = processWorkSpaceFilePath(file);
+ relationT.setText(s);
+ }
+ }
+
+
+ protected String processFileSystemFilePath(String path) {
+// if (filePathProcessor != null) {
+// String s = filePathProcessor.processFileSystemPath(path);
+// if (s != null) {
+// return s;
+// }
+// }
+ path = SmooksUIUtils.FILE_PRIX + path;
+ return path;
+ }
+
+
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * @param version the version to set
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * @return the segments
+ */
+ public String getSegments() {
+ return segments;
+ }
+
+ /**
+ * @param segments the segments to set
+ */
+ public void setSegments(String segments) {
+ this.segments = segments;
+ }
+
+ /**
+ * @return the componentDelimiter
+ */
+ public String getComponentDelimiter() {
+ return componentDelimiter;
+ }
+
+ /**
+ * @param componentDelimiter the componentDelimiter to set
+ */
+ public void setComponentDelimiter(String componentDelimiter) {
+ this.componentDelimiter = componentDelimiter;
+ }
+
+ /**
+ * @return the subComponentDelimiter
+ */
+ public String getSubComponentDelimiter() {
+ return subComponentDelimiter;
+ }
+
+ /**
+ * @param subComponentDelimiter the subComponentDelimiter to set
+ */
+ public void setSubComponentDelimiter(String subComponentDelimiter) {
+ this.subComponentDelimiter = subComponentDelimiter;
+ }
+
+ /**
+ * @return the fieldDelimiter
+ */
+ public String getFieldDelimiter() {
+ return fieldDelimiter;
+ }
+
+ /**
+ * @param fieldDelimiter the fieldDelimiter to set
+ */
+ public void setFieldDelimiter(String fieldDelimiter) {
+ this.fieldDelimiter = fieldDelimiter;
+ }
+
+ /**
+ * @return the segmentDelimiter
+ */
+ public String getSegmentDelimiter() {
+ return segmentDelimiter;
+ }
+
+ /**
+ * @param segmentDelimiter the segmentDelimiter to set
+ */
+ public void setSegmentDelimiter(String segmentDelimiter) {
+ this.segmentDelimiter = segmentDelimiter;
+ }
+
+ /**
+ * @return the ediFilePath
+ */
+ public String getEdiFilePath() {
+ return ediFilePath;
+ }
+
+ /**
+ * @param ediFilePath the ediFilePath to set
+ */
+ public void setEdiFilePath(String ediFilePath) {
+ this.ediFilePath = ediFilePath;
+ }
+
+
+ private void updatePageStatus(){
+ String error = null;
+ if(segments == null || segments.length() == 0){
+ error = "The xml root name can't be null";
+ }
+ this.setErrorMessage(error);
+ this.setPageComplete(error == null);
+ }
+
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileConfigPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileContainerSelectionPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileContainerSelectionPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileContainerSelectionPage.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.edimap.wizard;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDIMappingConfigFileContainerSelectionPage extends WizardNewFileCreationPage
{
+
+ public EDIMappingConfigFileContainerSelectionPage(String pageName, IStructuredSelection
selection) {
+ super(pageName, selection);
+ setTitle("EDI Mapping Configuration File Wizard Page");
+ setDescription("Create a new EDI mapping configuration file.");
+ setFileExtension("xml");
+ setFileName("edi-to-xml-mapping.xml");
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ validatePage();
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileContainerSelectionPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileWizard.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.edimap.wizard;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.model.medi.Delimiters;
+import org.jboss.tools.smooks.model.medi.Description;
+import org.jboss.tools.smooks.model.medi.DocumentRoot;
+import org.jboss.tools.smooks.model.medi.EdiMap;
+import org.jboss.tools.smooks.model.medi.MEdiFactory;
+import org.jboss.tools.smooks.model.medi.Segments;
+import org.jboss.tools.smooks.model.medi.util.MEdiResourceFactoryImpl;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDIMappingConfigFileWizard extends Wizard implements INewWizard {
+ private EDIMappingConfigFileContainerSelectionPage pathPage;
+
+ private EDIMappingConfigFileConfigPage configPage;
+
+ private IStructuredSelection selection;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+
+ final IPath containerPath = pathPage.getContainerFullPath();
+ final String fileName = pathPage.getFileName();
+
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ try {
+ doFinish(containerPath, fileName, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ try {
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ if (pathPage == null) {
+ pathPage = new EDIMappingConfigFileContainerSelectionPage("File Selection",
this.selection);
+ }
+ this.addPage(pathPage);
+ if (configPage == null) {
+ configPage = new EDIMappingConfigFileConfigPage("Config", this.selection);
+ }
+ this.addPage(configPage);
+ super.addPages();
+ }
+
+ private void doFinish(IPath containerPath, String fileName, IProgressMonitor monitor)
throws CoreException {
+ // create a sample file
+ monitor.beginTask("Creating " + fileName, 2);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource = root.findMember(containerPath);
+ IContainer container = null;
+ if (resource.exists() && resource instanceof IContainer) {
+ container = (IContainer) resource;
+ }
+ if (container == null)
+ throwCoreException("Container \"" + containerPath.toPortableString() +
"\" does not exist.");
+ final IFile configFile = container.getFile(new Path(fileName));
+ String extFileName = fileName + ".ext";
+ final IFile extFile = container.getFile(new Path(extFileName));
+ try {
+ // create config file
+ InputStream stream = openContentStream();
+ if (configFile.exists()) {
+ configFile.setContents(stream, true, true, monitor);
+ } else {
+ configFile.create(stream, true, monitor);
+ }
+ stream.close();
+ // create ext file:
+ createExtentionFile(extFile, monitor, configPage.getEdiFilePath());
+ } catch (IOException e) {
+ SmooksConfigurationActivator.getDefault().log(e);
+ }
+ monitor.worked(1);
+ monitor.setTaskName("Opening file with Smooks Editor.");
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, configFile);
+// page.openEditor(editorInput, SmooksMultiFormEditor.EDITOR_ID, true);
+ } catch (PartInitException e) {
+ SmooksConfigurationActivator.getDefault().log(e);
+ }
+ }
+ });
+ monitor.worked(1);
+ }
+
+ private InputStream openContentStream() throws IOException {
+ Resource resource = new MEdiResourceFactoryImpl().createResource(null);
+
+ DocumentRoot docRoot = MEdiFactory.eINSTANCE.createDocumentRoot();
+ resource.getContents().add(docRoot);
+
+ EdiMap map = MEdiFactory.eINSTANCE.createEdiMap();
+ docRoot.setEdimap(map);
+
+ Description description = MEdiFactory.eINSTANCE.createDescription();
+ map.setDescription(description);
+ initDescription(description);
+
+ Delimiters delimiters = MEdiFactory.eINSTANCE.createDelimiters();
+ map.setDelimiters(delimiters);
+ initDelimiters(delimiters);
+
+ Segments segments = MEdiFactory.eINSTANCE.createSegments();
+ map.setSegments(segments);
+ String se = configPage.getSegments();
+ if (se != null) {
+ segments.setXmltag(se);
+ }
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ resource.save(output, Collections.emptyMap());
+ return new ByteArrayInputStream(output.toByteArray());
+ }
+
+ private void initDelimiters(Delimiters delimiters) {
+ if (configPage != null) {
+ final String segment = configPage.getSegmentDelimiter();
+ if(segment != null){
+ delimiters.setSegment(segment);
+ }
+ final String field = configPage.getFieldDelimiter();
+ if(field != null){
+ delimiters.setField(field);
+ }
+ final String component = configPage.getComponentDelimiter();
+ if(component != null){
+ delimiters.setComponent(component);
+ }
+ final String subComponent = configPage.getSubComponentDelimiter();
+ if(subComponent != null){
+ delimiters.setSubComponent(subComponent);
+ }
+
+ }
+ }
+
+ private void initDescription(Description description) {
+ if (configPage != null) {
+ final String name = configPage.getName();
+ if (name != null) {
+ description.setName(name);
+ }
+ final String version = configPage.getVersion();
+ if (version != null) {
+ description.setVersion(version);
+ }
+ }
+ }
+
+ public static void createExtentionFile(IFile file, IProgressMonitor monitor, String
ediPath) throws CoreException,
+ IOException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ InputStream stream1 = createExtContentStream(ediPath);
+ if (file.exists()) {
+ file.setContents(stream1, true, true, monitor);
+ } else {
+ file.create(stream1, true, monitor);
+ }
+ stream1.close();
+ }
+
+ public static InputStream createExtContentStream(String filePath) {
+ String path = filePath;
+ if (path == null) {
+ path = "";
+ }
+ String contents = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + " <smooks-graphics-ext
xmlns=\"http://www.jboss.org/jbosstools/smooks/smooks-graphics-ext.x...
+ + " <input type=\"EDI\">\n" + "
<param name=\"path\">" + path + "</param>\n"
+ + " </input>\n" + " <graph/>\n" +
" </smooks-graphics-ext>";
+ return new ByteArrayInputStream(contents.getBytes());
+ }
+
+ private void throwCoreException(String message) throws CoreException {
+ IStatus status = new Status(IStatus.ERROR, SmooksConfigurationActivator.PLUGIN_ID,
IStatus.OK, message, null);
+ throw new CoreException(status);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/wizard/EDIMappingConfigFileWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.gef.tree.command;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class DeleteConnectionCommand extends Command {
+
+ private TreeNodeConnection connection;
+
+ public DeleteConnectionCommand(TreeNodeConnection connection) {
+ Assert.isNotNull(connection);
+ this.connection = connection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.commands.Command#canExecute()
+ */
+ @Override
+ public boolean canExecute() {
+ if (this.connection != null) {
+ return true;
+ }
+ return super.canExecute();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.commands.Command#canUndo()
+ */
+ @Override
+ public boolean canUndo() {
+ if (this.connection != null) {
+ if (connection.getSourceNode() != null && connection.getTargetNode() != null)
+ return true;
+ }
+ return super.canUndo();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ @Override
+ public void execute() {
+ super.execute();
+ this.connection.disconnect();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.commands.Command#redo()
+ */
+ @Override
+ public void redo() {
+ super.redo();
+ this.connection.disconnect();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.commands.Command#undo()
+ */
+ @Override
+ public void undo() {
+ super.undo();
+ this.connection.connect();
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/command/DeleteConnectionCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -6,7 +6,6 @@
import java.beans.PropertyChangeEvent;
import java.util.List;
-import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
@@ -47,7 +46,7 @@
if (!isSource) {
IFigure figure = getFigure();
if (figure instanceof TreeContainerFigure) {
- ((TreeContainerFigure) figure).setHeaderColor(ColorConstants.orange);
+// ((TreeContainerFigure) figure).setHeaderColor(ColorConstants.orange);
}
}
Point location = model.getLocation();
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -13,7 +13,10 @@
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeConnectionEditPolicy;
+import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeEndpointEditPolicy;
import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
@@ -27,7 +30,8 @@
@Override
protected void createEditPolicies() {
-
+ this.installEditPolicy(EditPolicy.CONNECTION_ROLE, new
TreeNodeConnectionEditPolicy());
+ this.installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new
TreeNodeEndpointEditPolicy());
}
public void changeLineAlpha(int alpha) {
@@ -38,7 +42,7 @@
TreeNodeConnection model = (TreeNodeConnection) getModel();
TreeNodeModel sourceModel = model.getSourceNode();
TreeNodeModel targetModel = model.getTargetNode();
- PolylineConnection connection1 = new PolylineConnection(){
+ PolylineConnection connection1 = new PolylineConnection() {
@Override
public void paintFigure(Graphics graphics) {
graphics.setAlpha(alpha);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -60,7 +60,6 @@
return false;
}
-
/*
* (non-Javadoc)
*
@@ -174,8 +173,13 @@
public void propertyChange(PropertyChangeEvent evt) {
String proName = evt.getPropertyName();
- if (TreeNodeModel.PRO_ADD_CHILD.equals(proName) ||
TreeNodeModel.PRO_REMOVE_CHILD.equals(proName)) {
+ if (TreeNodeModel.PRO_FORCE_VISUAL_CHANGED.equals(proName)) {
+ refreshVisuals();
+ }
+ if (TreeNodeModel.PRO_ADD_CHILD.equals(proName) ||
TreeNodeModel.PRO_REMOVE_CHILD.equals(proName)
+ || TreeNodeModel.PRO_FORCE_CHIDLREN_CHANGED.equals(proName)) {
refreshChildren();
+
}
if (TreeNodeModel.PRO_ADD_SOURCE_CONNECTION.equals(proName)
|| TreeNodeModel.PRO_REMOVE_SOURCE_CONNECTION.equals(proName)) {
@@ -185,6 +189,11 @@
|| TreeNodeModel.PRO_REMOVE_TARGET_CONNECTION.equals(proName)) {
refreshTargetConnections();
}
+
+ if (TreeNodeModel.PRO_FORCE_CONNECTION_CHANGED.equals(proName)) {
+ refreshSourceConnections();
+ refreshTargetConnections();
+ }
}
protected void recordBounds(SmooksGraphicsExtType graphicsExt, Rectangle bounds) {
@@ -325,4 +334,8 @@
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
return new LeftOrRightAnchor(getAnchorFigure());
}
+
+ public CreateConnectionCommand createCreateConnectionCommand() {
+ return null;
+ }
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeConnectionEditPolicy.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeConnectionEditPolicy.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeConnectionEditPolicy.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.gef.tree.editpolicy;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ConnectionEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+import org.jboss.tools.smooks.gef.tree.command.DeleteConnectionCommand;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class TreeNodeConnectionEditPolicy extends ConnectionEditPolicy {
+
+ public TreeNodeConnectionEditPolicy() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editpolicies.ConnectionEditPolicy#getDeleteCommand(org
+ * .eclipse.gef.requests.GroupRequest)
+ */
+ @Override
+ protected Command getDeleteCommand(GroupRequest request) {
+ Object connection = getHost().getModel();
+ if (connection != null && connection instanceof TreeNodeConnection) {
+ DeleteConnectionCommand command = new DeleteConnectionCommand((TreeNodeConnection)
connection);
+ return command;
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeConnectionEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeEndpointEditPolicy.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeEndpointEditPolicy.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeEndpointEditPolicy.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.gef.tree.editpolicy;
+
+import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class TreeNodeEndpointEditPolicy extends ConnectionEndpointEditPolicy {
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeEndpointEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -9,6 +9,7 @@
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.jboss.tools.smooks.gef.tree.editparts.CreateConnectionCommand;
+import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
/**
@@ -33,7 +34,7 @@
if (!((TreeNodeModel) targetModel).canLinkWithSource(((CreateConnectionCommand)
command).getSource()))
return null;
Object source = ((CreateConnectionCommand) command).getSource();
- if(source instanceof TreeNodeModel){
+ if (source instanceof TreeNodeModel) {
if (!((TreeNodeModel) source).canLinkWithTarget(targetModel))
return null;
}
@@ -62,7 +63,14 @@
if (model != null && model instanceof TreeNodeModel) {
if (!((TreeNodeModel) model).isLinkable())
return null;
- CreateConnectionCommand command = new CreateConnectionCommand();
+ EditPart hostPart = getHost();
+ CreateConnectionCommand command = null;
+ if (hostPart instanceof TreeNodeEditPart) {
+ command = ((TreeNodeEditPart) hostPart).createCreateConnectionCommand();
+ }
+ if (command == null) {
+ command = new CreateConnectionCommand();
+ }
command.setSource((TreeNodeModel) model);
request.setStartCommand(command);
return command;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java 2009-07-14
08:14:39 UTC (rev 16560)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java 2009-07-14
10:23:19 UTC (rev 16561)
@@ -31,6 +31,12 @@
public static final String PRO_REMOVE_TARGET_CONNECTION =
"_pro_remove_target_connected";
public static final String PRO_TEXT_CHANGED = "_pro_text_changed";
+
+ public static final String PRO_FORCE_VISUAL_CHANGED =
"_pro_force_text_changed";
+
+ public static final String PRO_FORCE_CHIDLREN_CHANGED =
"_pro_force_children_changed";
+
+ public static final String PRO_FORCE_CONNECTION_CHANGED =
"_pro_force_connection_changed";
protected Object data = null;
@@ -123,6 +129,7 @@
TreeNodeModel node = (TreeNodeModel) iterator.next();
Object data = node.getData();
if (!graphicalChildExist(data, models)) {
+ disconnectAllConnections(node);
children.remove(node);
node.setParent(null);
}
@@ -135,6 +142,34 @@
return children;
}
+ protected void disconnectAllConnections(TreeNodeModel node) {
+ List<TreeNodeConnection> sourceConnections = node.getSourceConnections();
+ List<TreeNodeConnection> targetConnections = node.getTargetConnections();
+ List<TreeNodeConnection> tempSourceConnections = new
ArrayList<TreeNodeConnection>(sourceConnections);
+ List<TreeNodeConnection> tempTargetConnections = new
ArrayList<TreeNodeConnection>(targetConnections);
+
+ for (Iterator<?> iterator2 = tempTargetConnections.iterator();
iterator2.hasNext();) {
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
+ treeNodeConnection.disconnect();
+ }
+
+ for (Iterator<?> iterator2 = tempSourceConnections.iterator();
iterator2.hasNext();) {
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
+ treeNodeConnection.disconnect();
+ }
+
+ tempSourceConnections.clear();
+ tempTargetConnections.clear();
+ tempSourceConnections = null;
+ tempTargetConnections = null;
+
+ List<TreeNodeModel> children = node.getChildren();
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ TreeNodeModel treeNodeModel = (TreeNodeModel) iterator.next();
+ disconnectAllConnections(treeNodeModel);
+ }
+ }
+
protected boolean graphicalChildExist(Object model, Object[] models) {
for (int i = 0; i < models.length; i++) {
if (model == models[i]) {
@@ -269,5 +304,17 @@
public List<TreeNodeConnection> getTargetConnections() {
return targetConnections;
}
+
+ public void fireChildrenChanged(){
+ support.firePropertyChange(PRO_FORCE_CHIDLREN_CHANGED, new Object(), null);
+ }
+
+ public void fireConnectionChanged(){
+ support.firePropertyChange(PRO_FORCE_CONNECTION_CHANGED, new Object(), null);
+ }
+
+ public void fireVisualChanged(){
+ support.firePropertyChange(PRO_FORCE_VISUAL_CHANGED, new Object(), null);
+ }
}