Author: DartPeng
Date: 2009-01-20 02:09:55 -0500 (Tue, 20 Jan 2009)
New Revision: 13135
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/SelectorAttributes.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionFilter.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionSection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/IXMLNode.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorGraphicalModelListener.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorMappingAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanPropertiesSection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/CompositeSelectionProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TransformDataTreeViewer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLPropertiesSection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java
Log:
JBIDE-3592
Fix the bug and add a new property section for edit the connection line's properties (
selector sperator , selector generation policy).
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -101,7 +101,7 @@
if (connections.size() == 1) {
LineConnectionModel line = (LineConnectionModel) connections.get(0);
Object bindingType = line
- .getProperty(BeanPopulatorMappingAnalyzer.BINDING_TYPE);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE);
if (!BeanPopulatorMappingAnalyzer.REFERENCE_BINDING
.equals(bindingType)) {
if (sourceGraphModel instanceof SourceModel) {
@@ -171,7 +171,7 @@
for (Iterator iterator = parentConnections.iterator(); iterator
.hasNext();) {
LineConnectionModel object = (LineConnectionModel) iterator.next();
- if (object.getProperty(Java2JavaAnalyzer.REFERENCE_RESOURCE_CONFIG) == null) {
+ if (object.getProperty(Java2JavaAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG) == null) {
return false;
}
}
@@ -186,7 +186,7 @@
for (Iterator iterator = connections.iterator(); iterator.hasNext();) {
LineConnectionModel line = (LineConnectionModel) iterator.next();
Object bindingType = line
- .getProperty(BeanPopulatorMappingAnalyzer.BINDING_TYPE);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE);
if (BeanPopulatorMappingAnalyzer.BEAN_CREATION.equals(bindingType)) {
hasBeanCreation = true;
break;
@@ -252,7 +252,7 @@
beanCreationLineCommand
.setTarget((IConnectableModel) cloneTargetGraphModel);
PropertyModel bindingType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.BEAN_CREATION);
beanCreationLineCommand.addPropertyModel(bindingType);
commands.add(beanCreationLineCommand);
@@ -263,7 +263,7 @@
referenceLineCommand
.setTarget((IConnectableModel) cloneTargetGraphModel);
PropertyModel referenceType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.REFERENCE_BINDING);
referenceLineCommand.addPropertyModel(referenceType);
commands.add(referenceLineCommand);
@@ -320,7 +320,7 @@
if (!UIUtils.isInstanceCreatingConnection(source, t)) {
if (t instanceof JavaBeanModel) {
PropertyModel bindingType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.PROPERTY_BINDING);
command.addPropertyModel(bindingType);
Class clazz = ((JavaBeanModel) t).getBeanClass();
@@ -334,13 +334,13 @@
} else {
if (s instanceof TargetModel) {
PropertyModel bindingType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.REFERENCE_BINDING);
command.addPropertyModel(bindingType);
}
if (s instanceof SourceModel) {
PropertyModel bindingType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.BEAN_CREATION);
command.addPropertyModel(bindingType);
}
@@ -358,78 +358,6 @@
return true;
}
- // private CreateConnectionCommand connectRootNode(Object source,
- // Object target, SmooksConfigurationFileGenerateContext context) {
- // JavaBeanModel javaBeanTarget = (JavaBeanModel) target;
- // Object sourceModel = source;
- //
- // JavaBeanModel targetRoot = javaBeanTarget.getParent();
- // JavaBeanModel tempTargetRoot = targetRoot;
- // while (tempTargetRoot != null) {
- // targetRoot = tempTargetRoot;
- // tempTargetRoot = tempTargetRoot.getParent();
- // }
- // Object sourceRoot = null;
- // if (sourceModel instanceof JavaBeanModel) {
- // sourceRoot = ((JavaBeanModel) sourceModel).getParent();
- // JavaBeanModel sourceTempRoot = (JavaBeanModel) sourceRoot;
- // while (sourceTempRoot != null) {
- // sourceRoot = sourceTempRoot;
- // sourceTempRoot = ((JavaBeanModel) sourceTempRoot).getParent();
- // }
- // }
- //
- // if (sourceModel instanceof AbstractXMLObject) {
- // sourceRoot = ((AbstractXMLObject) sourceModel).getParent();
- // AbstractXMLObject tempParent = ((AbstractXMLObject) sourceRoot)
- // .getParent();
- // while (!(tempParent instanceof TagList)) {
- // sourceRoot = tempParent;
- // tempParent = tempParent.getParent();
- // }
- // }
- // GraphRootModel graphRoot = context.getGraphicalRootModel();
- // if (sourceRoot == null || targetRoot == null)
- // return null;
- // AbstractStructuredDataModel graphSourceRoot = UIUtils.findGraphModel(
- // graphRoot, sourceRoot);
- // AbstractStructuredDataModel graphTargetRoot = UIUtils.findGraphModel(
- // graphRoot, targetRoot);
- //
- // List<TargetModel> graphTargetList = graphRoot.loadTargetModelList();
- // boolean isConnected = false;
- // for (Iterator iterator = graphTargetList.iterator(); iterator.hasNext();)
- // {
- // TargetModel targetModel = (TargetModel) iterator.next();
- // if (targetModel == graphTargetRoot) {
- // List connections = targetModel.getModelTargetConnections();
- // for (Iterator iterator2 = connections.iterator(); iterator2
- // .hasNext();) {
- // Object object = (Object) iterator2.next();
- // if (object instanceof LineConnectionModel) {
- // Object cs = ((LineConnectionModel) object).getSource();
- // if (cs == graphSourceRoot) {
- // isConnected = true;
- // break;
- // }
- // }
- // }
- // }
- // if (isConnected)
- // break;
- // }
- //
- // if (!isConnected) {
- // CreateConnectionCommand connectionCommand = new
- // CreateConnectionCommand();
- // connectionCommand.setSource(graphSourceRoot);
- // connectionCommand.setTarget(graphTargetRoot);
- // return connectionCommand;
- // }
- //
- // return null;
- // }
-
private void fillCreateParentLinkCommand(CompoundCommand compoundCommand,
Object source, JavaBeanModel target,
SmooksConfigurationFileGenerateContext context) {
@@ -478,7 +406,7 @@
Class clazz = ((JavaBeanModel) targetParent)
.getBeanClass();
PropertyModel bindingType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.PROPERTY_BINDING);
connectionCommand.addPropertyModel(bindingType);
if (clazz != null && clazz != String.class) {
@@ -490,13 +418,13 @@
} else {
if (sourceParentGraphModel instanceof TargetModel) {
PropertyModel bindingType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.REFERENCE_BINDING);
connectionCommand.addPropertyModel(bindingType);
}
if (sourceParentGraphModel instanceof SourceModel) {
PropertyModel bindingType = new PropertyModel(
- BeanPopulatorMappingAnalyzer.BINDING_TYPE,
+ BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.BEAN_CREATION);
connectionCommand.addPropertyModel(bindingType);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -23,17 +23,17 @@
import java.util.List;
import java.util.Properties;
-import
org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ExtendsWildcardType;
import org.jboss.tools.smooks.analyzer.IValidatable;
import org.jboss.tools.smooks.javabean.uitils.JavaPropertyUtils;
import org.jboss.tools.smooks.ui.IXMLStructuredObject;
+import org.jboss.tools.smooks.xml.model.ITransformTreeNode;
/**
* @author Dart Peng
*
*/
public class JavaBeanModel implements IValidatable, IXMLStructuredObject,
- Cloneable {
+ Cloneable , ITransformTreeNode{
private Properties extendProperties = new Properties();
@@ -90,7 +90,7 @@
this.isRootClassModel = isRootClassModel;
}
- public void addPropertyChangeListener(PropertyChangeListener listener) {
+ public void addNodePropetyChangeListener(PropertyChangeListener listener) {
PropertyChangeListener[] array = support.getPropertyChangeListeners();
for (int i = 0; i < array.length; i++) {
if(listener == array[i]) return;
@@ -98,7 +98,7 @@
support.addPropertyChangeListener(listener);
}
- public void removePropertyChangeListener(PropertyChangeListener listener) {
+ public void removeNodePropetyChangeListener(PropertyChangeListener listener) {
support.removePropertyChangeListener(listener);
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/SelectorAttributes.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/SelectorAttributes.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/SelectorAttributes.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -0,0 +1,29 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.javabean.model;
+
+import org.jboss.tools.smooks.javabean.ui.BeanPopulatorMappingAnalyzer;
+
+/**
+ * @author Dart
+ *
+ */
+public class SelectorAttributes {
+ private String selectorSperator = " ";
+ private String selectorPolicy = BeanPopulatorMappingAnalyzer.FULL_PATH;
+ public String getSelectorSperator() {
+ return selectorSperator;
+ }
+ public void setSelectorSperator(String selectorSperator) {
+ this.selectorSperator = selectorSperator;
+ }
+ public String getSelectorPolicy() {
+ return selectorPolicy;
+ }
+ public void setSelectorPolicy(String selectorPolicy) {
+ this.selectorPolicy = selectorPolicy;
+ }
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/SelectorAttributes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionFilter.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionFilter.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionFilter.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.javabean.ui;
+
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.ui.AbstractConnectionModelSectionFilter;
+import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class BeanPopulatorConnectionFilter extends
+ AbstractConnectionModelSectionFilter {
+
+ public boolean select(Object toTest) {
+ Object target = this.getReferenceTargetObject(toTest);
+ if (target != null && target instanceof JavaBeanModel) {
+ LineConnectionModel connection = getConnectionModel(toTest);
+ if (BeanPopulatorMappingAnalyzer.REFERENCE_BINDING
+ .equals(connection
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE))) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionSection.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionSection.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionSection.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -0,0 +1,240 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.javabean.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+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.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+import org.jboss.tools.smooks.javabean.model.SelectorAttributes;
+import org.jboss.tools.smooks.ui.AbstractSmooksPropertySection;
+import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
+import org.jboss.tools.smooks.ui.gef.model.PropertyModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class BeanPopulatorConnectionSection extends
+ AbstractSmooksPropertySection {
+
+ private Button allPathButton;
+ private Button nameOnlyButton;
+ private Button includeParentButton;
+ private Button ignoreRootButton;
+ private CCombo speratorCombox;
+
+ @Override
+ public void createControls(Composite parent,
+ TabbedPropertySheetPage tabbedPropertySheetPage) {
+ super.createControls(parent, tabbedPropertySheetPage);
+ TabbedPropertySheetWidgetFactory factory = tabbedPropertySheetPage
+ .getWidgetFactory();
+
+ Section section = createRootSection(factory, parent);
+ section.setText("BeanPopulator Connection"); //$NON-NLS-1$
+ Composite controlComposite = factory.createComposite(section);
+ section.setClient(controlComposite);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ controlComposite.setLayout(layout);
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+
+ factory.createLabel(controlComposite, "Selector text sperator : ");
+ speratorCombox = factory.createCCombo(controlComposite);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ speratorCombox.setLayoutData(gd);
+
+ String[] sperators = BeanPopulatorMappingAnalyzer.SELECTOR_SPERATORS;
+ for (int i = 0; i < sperators.length; i++) {
+ if (sperators[i].equals(" ")) {
+ speratorCombox.add("<space>");
+ continue;
+ }
+ speratorCombox.add(sperators[i]);
+ }
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ factory.createLabel(controlComposite, "Selector generate policies:")
+ .setLayoutData(gd);
+
+ Composite policiesComposite = factory.createComposite(controlComposite);
+ policiesComposite.setLayoutData(gd);
+
+ GridLayout gl1 = new GridLayout();
+ gl1.numColumns = 4;
+ gl1.marginHeight = 0;
+ policiesComposite.setLayout(gl1);
+
+ allPathButton = factory.createButton(policiesComposite, "Full path",
+ SWT.RADIO);
+ nameOnlyButton = factory.createButton(policiesComposite, "Name only",
+ SWT.RADIO);
+ includeParentButton = factory.createButton(policiesComposite,
+ "Include parent name", SWT.RADIO);
+ ignoreRootButton = factory.createButton(policiesComposite,
+ "Ignore root node name", SWT.RADIO);
+
+ hookButtons();
+ hookSperatorCombox();
+ }
+
+ private void changeTheSelectorGenerationPolicy(String policy) {
+ if(policy == null) return;
+ SelectorAttributes attribute = getSelectorAttributes();
+ if (attribute != null) {
+ if(policy.equals(attribute.getSelectorPolicy())) return;
+ attribute.setSelectorPolicy(policy);
+ }
+ LineConnectionModel line = getLineConnectionModel();
+ line
+ .addPropertyModel(
+ BeanPopulatorMappingAnalyzer.PRO_SELECTOR_ATTRIBUTES,
+ attribute);
+ fireDirty();
+ }
+
+ protected void hookButtons() {
+ allPathButton.addSelectionListener(new PolicyButtonSelectionListener(
+ BeanPopulatorMappingAnalyzer.FULL_PATH));
+ nameOnlyButton.addSelectionListener(new PolicyButtonSelectionListener(
+ BeanPopulatorMappingAnalyzer.ONLY_NAME));
+ includeParentButton
+ .addSelectionListener(new PolicyButtonSelectionListener(
+ BeanPopulatorMappingAnalyzer.INCLUDE_PARENT));
+ ignoreRootButton
+ .addSelectionListener(new PolicyButtonSelectionListener(
+ BeanPopulatorMappingAnalyzer.IGNORE_ROOT));
+ }
+
+ protected void hookSperatorCombox() {
+ speratorCombox.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ if (isLock())
+ return;
+ String sperator = speratorCombox.getText();
+ if (sperator == null) {
+ sperator = " ";
+ }
+ sperator = sperator.trim();
+ if (sperator.length() == 0)
+ sperator = " ";
+
+ if (sperator.equals("<space>")) {
+ sperator = " ";
+ }
+ SelectorAttributes sa = getSelectorAttributes();
+ if (sa != null) {
+ if (sperator.equals(sa.getSelectorSperator()))
+ return;
+ sa.setSelectorSperator(sperator);
+ getLineConnectionModel()
+ .addPropertyModel(
+ new PropertyModel(
+ BeanPopulatorMappingAnalyzer.PRO_SELECTOR_ATTRIBUTES,
+ sa));
+ }
+ fireDirty();
+ }
+
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ public void refresh() {
+ super.refresh();
+ lockEventFire();
+ String sperator = getSperator();
+ if (sperator == null) {
+ sperator = "<space>";
+ } else {
+ if (sperator.equals(" ")) {
+ sperator = "<space>";
+ }
+ }
+ this.speratorCombox.setText(sperator);
+
+ String policy = getSelectorPolicy();
+ if (policy == null) {
+ policy = BeanPopulatorMappingAnalyzer.FULL_PATH;
+ }
+ allPathButton.setSelection(false);
+ nameOnlyButton.setSelection(false);
+ ignoreRootButton.setSelection(false);
+ includeParentButton.setSelection(false);
+ if (policy.equals(BeanPopulatorMappingAnalyzer.FULL_PATH)) {
+ this.allPathButton.setSelection(true);
+ }
+ if (policy.equals(BeanPopulatorMappingAnalyzer.ONLY_NAME)) {
+ this.nameOnlyButton.setSelection(true);
+ }
+ if (policy.equals(BeanPopulatorMappingAnalyzer.IGNORE_ROOT)) {
+ this.ignoreRootButton.setSelection(true);
+ }
+ if (policy.equals(BeanPopulatorMappingAnalyzer.INCLUDE_PARENT)) {
+ this.includeParentButton.setSelection(true);
+ }
+
+ unLockEventFire();
+ }
+
+ protected SelectorAttributes getSelectorAttributes() {
+ LineConnectionModel connection = getLineConnectionModel();
+ if (connection != null) {
+ return (SelectorAttributes) connection
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_SELECTOR_ATTRIBUTES);
+ }
+ return null;
+ }
+
+ protected String getSperator() {
+ SelectorAttributes sa = getSelectorAttributes();
+ if (sa != null) {
+ return sa.getSelectorSperator();
+ }
+ return null;
+ }
+
+ protected String getSelectorPolicy() {
+ SelectorAttributes sa = getSelectorAttributes();
+ if (sa != null) {
+ return sa.getSelectorPolicy();
+ }
+ return null;
+ }
+
+ private class PolicyButtonSelectionListener extends SelectionAdapter {
+ private String policy;
+
+ public PolicyButtonSelectionListener(String policy) {
+ this.policy = policy;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(isLock()) return;
+ changeTheSelectorGenerationPolicy(policy);
+ }
+
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorConnectionSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorGraphicalModelListener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorGraphicalModelListener.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorGraphicalModelListener.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -10,8 +10,10 @@
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
import org.jboss.tools.smooks.javabean.model.JavaBeanList;
import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.javabean.model.SelectorAttributes;
import org.jboss.tools.smooks.model.ParamType;
import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.ResourceType;
@@ -20,6 +22,7 @@
import org.jboss.tools.smooks.model.util.SmooksModelConstants;
import org.jboss.tools.smooks.model.util.SmooksModelUtils;
import org.jboss.tools.smooks.ui.IXMLStructuredObject;
+import org.jboss.tools.smooks.ui.editors.SmooksFormEditor;
import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataConnectionModel;
import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
import org.jboss.tools.smooks.ui.gef.model.GraphRootModel;
@@ -148,14 +151,14 @@
private void setReferenceResourceConfig(ResourceConfigType resourceConfig,
LineConnectionModel connection) {
- connection.updateAndAddProperty(
- BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG,
+ connection.addPropertyModel(
+ BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG,
resourceConfig);
}
private ResourceConfigType getResourceConfig(LineConnectionModel line) {
Object obj = line
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG);
if (obj != null && obj instanceof ResourceConfigType) {
return (ResourceConfigType) obj;
}
@@ -189,7 +192,7 @@
.next();
if (isBeanCreationConnection(connection)) {
Object obj = connection
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG);
if (obj == null || !(obj instanceof ResourceConfigType))
return null;
return (ResourceConfigType) obj;
@@ -244,23 +247,14 @@
LineConnectionModel line) {
JavaBeanModel target = (JavaBeanModel) ((AbstractStructuredDataModel) line
.getTarget()).getReferenceEntityModel();
- JavaBeanModel targetParent = target.getParent();
Object source = ((AbstractStructuredDataModel) line.getSource())
.getReferenceEntityModel();
String propertyName = target.getName();
- //
- IXMLStructuredObject contextNode = ignoreRootParentNode((IXMLStructuredObject)
source);
- if (targetParent.isList() || targetParent.isArray()) {
- propertyName = null;
- //
- contextNode = parentNode((IXMLStructuredObject) source);
- }
String currentSelectorName = null;
if (source instanceof IXMLStructuredObject) {
- currentSelectorName = UIUtils.generatePath(
- (IXMLStructuredObject) source, contextNode, " ", false);
+ currentSelectorName = UIUtils.generateFullPath(
+ (IXMLStructuredObject) source, " ");
}
-
if (currentSelectorName == null)
return;
addBindingToParamType(resourceConfig, propertyName,
@@ -283,8 +277,19 @@
line,
binding,
new String[] {
- "property", "selector",
BeanPopulatorMappingAnalyzer.BINDING_TYPE,
BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG }); //$NON-NLS-1$ //$NON-NLS-2$
-
+ "property", "selector",
BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE,
BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG }); //$NON-NLS-1$
//$NON-NLS-2$
+ if (!this.isReferenceBindingConnection(line)) {
+ PropertyModel bindingType = new PropertyModel(
+ BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG,
+ resourceConfig);
+ line.getProperties().add(bindingType);
+ SelectorAttributes sa = new SelectorAttributes();
+ sa.setSelectorPolicy(BeanPopulatorMappingAnalyzer.FULL_PATH);
+ sa.setSelectorSperator(" ");
+ PropertyModel selectorProperty = new PropertyModel(
+ BeanPopulatorMappingAnalyzer.PRO_SELECTOR_ATTRIBUTES, sa);
+ line.getProperties().add(selectorProperty);
+ }
}
protected void removeResourceConfigAssociatedConnections(
@@ -318,7 +323,7 @@
LineConnectionModel connection1 = (LineConnectionModel) iterator2
.next();
if (referenceResourceConfig == connection1
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG)) {
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG)) {
connection1.disConnect();
}
}
@@ -330,7 +335,7 @@
LineConnectionModel connection2 = (LineConnectionModel) iterator2
.next();
if (referenceResourceConfig == connection2
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG)) {
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG)) {
connection2.disConnect();
}
}
@@ -342,7 +347,7 @@
protected void removeResourceConfig(LineConnectionModel line,
SmooksConfigurationFileGenerateContext context) {
Object value = line
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG);
if (value == null || !(value instanceof ResourceConfigType))
return;
ResourceConfigType resourceConfig = (ResourceConfigType) value;
@@ -367,24 +372,31 @@
EditingDomain domain = context.getDomain();
UIUtils.addResourceConfigType(domain, listType, resourceConfig);
PropertyModel bindingModel = new PropertyModel(
- BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG,
+ BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG,
resourceConfig);
+ SelectorAttributes sa = new SelectorAttributes();
+ sa.setSelectorPolicy(BeanPopulatorMappingAnalyzer.FULL_PATH);
+ sa.setSelectorSperator(" ");
+ PropertyModel selectorProperty = new PropertyModel(
+ BeanPopulatorMappingAnalyzer.PRO_SELECTOR_ATTRIBUTES, sa);
((LineConnectionModel) graphicalModel).addPropertyModel(bindingModel);
+ ((LineConnectionModel) graphicalModel)
+ .addPropertyModel(selectorProperty);
}
private boolean isPropertyBindingConnection(LineConnectionModel connection) {
return BeanPopulatorMappingAnalyzer.PROPERTY_BINDING.equals(connection
- .getProperty(BeanPopulatorMappingAnalyzer.BINDING_TYPE));
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE));
}
private boolean isReferenceBindingConnection(LineConnectionModel connection) {
return BeanPopulatorMappingAnalyzer.REFERENCE_BINDING.equals(connection
- .getProperty(BeanPopulatorMappingAnalyzer.BINDING_TYPE));
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE));
}
private boolean isBeanCreationConnection(LineConnectionModel connection) {
return BeanPopulatorMappingAnalyzer.BEAN_CREATION.equals(connection
- .getProperty(BeanPopulatorMappingAnalyzer.BINDING_TYPE));
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE));
}
protected void configNewResourceConfig(ResourceConfigType resourceConfig,
@@ -395,7 +407,8 @@
.getReferenceEntityModel();
String sourceSelector = null;
if (source instanceof IXMLStructuredObject) {
- sourceSelector = ((IXMLStructuredObject) source).getNodeName();
+ sourceSelector = UIUtils.generateFullPath(
+ (IXMLStructuredObject) source, " ");
}
if (sourceSelector != null) {
resourceConfig.setSelector(sourceSelector);
@@ -438,18 +451,84 @@
public void modelChanged(Object graphicalModel,
SmooksConfigurationFileGenerateContext context,
PropertyChangeEvent event) {
- if(graphicalModel instanceof LineConnectionModel){
- String pm = event.getPropertyName();
- if(AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_CHANGE.equals(pm)){
- if(event.getNewValue() != null){
- if(event.getOldValue() != null){
- PropertyModel model = (PropertyModel)event.getNewValue();
+ LineConnectionModel line = null;
+ if (graphicalModel instanceof LineConnectionModel) {
+ line = (LineConnectionModel) graphicalModel;
+ }
+ String pm = event.getPropertyName();
+ if (pm
+ .equals(AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_UPDATE)) {
+ Object obj = event.getNewValue();
+ if (obj != null && obj instanceof PropertyModel && line != null) {
+ String name = ((PropertyModel) obj).getName();
+ if (name
+ .equals(BeanPopulatorMappingAnalyzer.PRO_SELECTOR_ATTRIBUTES)) {
+ SelectorAttributes sa = (SelectorAttributes) ((PropertyModel) obj)
+ .getValue();
+ if (sa != null) {
+ if (isBeanCreationConnection(line)) {
+ modifyResourceConfigSelector(line, sa);
+ }
+ if (isPropertyBindingConnection(line)) {
+ modifyPropertyBindingSelector(line, sa);
+ }
}
}
}
}
}
+ protected void modifyResourceConfigSelector(LineConnectionModel line,
+ SelectorAttributes sa) {
+ ResourceConfigType resourceConfig = getResourceConfig(line);
+ if (resourceConfig != null) {
+ AbstractStructuredDataModel source = (AbstractStructuredDataModel) line
+ .getSource();
+ Object s = source.getReferenceEntityModel();
+ if (s instanceof IXMLStructuredObject) {
+ String selector = UIUtils.generatePath(
+ (IXMLStructuredObject) s, sa);
+ if (selector != null) {
+ resourceConfig.setSelector(selector);
+ return;
+ }
+ }
+ }
+ }
+
+ protected void modifyPropertyBindingSelector(LineConnectionModel line,
+ SelectorAttributes sa) {
+ ResourceConfigType resourceConfig = getResourceConfig(line);
+ if (resourceConfig != null) {
+ AbstractStructuredDataModel source = (AbstractStructuredDataModel) line
+ .getSource();
+ AbstractStructuredDataModel target = (AbstractStructuredDataModel) line
+ .getTarget();
+ Object t = target.getReferenceEntityModel();
+ JavaBeanModel targetModel = null;
+ if (t instanceof JavaBeanModel) {
+ targetModel = (JavaBeanModel) t;
+ }
+ if (targetModel == null)
+ return;
+ Object s = source.getReferenceEntityModel();
+ if (s instanceof IXMLStructuredObject) {
+ String selector = UIUtils.generatePath(
+ (IXMLStructuredObject) s, sa);
+ if (selector != null) {
+ String pro = targetModel.getName();
+ AnyType binding = SmooksModelUtils.getBindingViaProperty(
+ resourceConfig, pro);
+ if (binding == null)
+ return;
+ SmooksModelUtils.setPropertyValueToAnyType(selector,
+ SmooksModelUtils.ATTRIBUTE_SELECTOR, binding);
+ return;
+ }
+ }
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -482,7 +561,7 @@
protected void removeReferenceBinding(LineConnectionModel line,
SmooksConfigurationFileGenerateContext context) {
Object value = line
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG);
if (value == null || !(value instanceof ResourceConfigType))
return;
ResourceConfigType resourceConfig = (ResourceConfigType) value;
@@ -508,10 +587,11 @@
for (Iterator iterator = connections.iterator(); iterator.hasNext();) {
LineConnectionModel connection = (LineConnectionModel) iterator
.next();
- if (BeanPopulatorMappingAnalyzer.BEAN_CREATION.equals(connection
- .getProperty(BeanPopulatorMappingAnalyzer.BINDING_TYPE))) {
+ if (BeanPopulatorMappingAnalyzer.BEAN_CREATION
+ .equals(connection
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE))) {
Object obj = connection
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG);
if (obj == null || !(obj instanceof ResourceConfigType)) {
} else {
@@ -526,7 +606,7 @@
protected void removePropertyBinding(LineConnectionModel line,
SmooksConfigurationFileGenerateContext context) {
Object value = line
- .getProperty(BeanPopulatorMappingAnalyzer.REFERENCE_RESOURCE_CONFIG);
+ .getProperty(BeanPopulatorMappingAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG);
if (value == null || !(value instanceof ResourceConfigType))
return;
ResourceConfigType resourceConfig = (ResourceConfigType) value;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorMappingAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorMappingAnalyzer.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/BeanPopulatorMappingAnalyzer.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -14,6 +14,7 @@
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.javabean.model.JavaBeanList;
import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.javabean.model.SelectorAttributes;
import org.jboss.tools.smooks.model.AbstractResourceConfig;
import org.jboss.tools.smooks.model.ParamType;
import org.jboss.tools.smooks.model.ResourceConfigType;
@@ -31,16 +32,28 @@
*
*/
public class BeanPopulatorMappingAnalyzer implements IMappingAnalyzer {
- public static final String BINDING_TYPE = "bindingType";
+ public static final String PRO_BINDING_TYPE = "bindingType";
- public static final String REFERENCE_RESOURCE_CONFIG =
"reference_resourceConfig";
+ public static final String PRO_REFERENCE_RESOURCE_CONFIG =
"reference_resourceConfig";
+ public static final String PRO_SELECTOR_ATTRIBUTES =
"__pro_selector_attributes";
+
public static final String BEAN_CREATION = "beanCreation";
public static final String PROPERTY_BINDING = "propertyBinding";
public static final String REFERENCE_BINDING = "referenceBinding";
+ public static final String[] SELECTOR_SPERATORS = new String[] { " ",
"/",
+ "\\" };
+ public static final String ONLY_NAME = "only_name";
+
+ public static final String FULL_PATH = "full_path";
+
+ public static final String IGNORE_ROOT = "ignore_root";
+
+ public static final String INCLUDE_PARENT = "include_parent";
+
/*
* (non-Javadoc)
*
@@ -136,23 +149,26 @@
bindingClass = bindingClass.trim();
JavaBeanModel targetNode = findJavaBeanFrombeanList(
- bindingClass, targetModel, mappingList , false);
+ bindingClass, targetModel, mappingList, false);
if (targetNode == null) {
throw new RuntimeException(
"Can't find the class node : " + bindingClass);
}
-
+ SelectorAttributes selectorAttributes = UIUtils
+ .guessSelectorProperty(selector, sourceNode);
MappingModel mapping = new MappingModel(sourceNode,
targetNode);
PropertyModel bindingProperty = new PropertyModel();
- bindingProperty.setName(BINDING_TYPE);
+ bindingProperty.setName(PRO_BINDING_TYPE);
bindingProperty.setValue(BEAN_CREATION);
mapping.getProperties().add(bindingProperty);
PropertyModel referenceProperty = new PropertyModel(
- REFERENCE_RESOURCE_CONFIG, resourceConfig);
+ PRO_REFERENCE_RESOURCE_CONFIG, resourceConfig);
mapping.getProperties().add(referenceProperty);
-
+ mapping.getProperties().add(
+ new PropertyModel(PRO_SELECTOR_ATTRIBUTES,
+ selectorAttributes));
mappingList.getMappingModelList().add(mapping);
mappingList.addResourceConfig(resourceConfig);
@@ -210,7 +226,8 @@
continue;
beanClass = beanClass.trim();
childSourceNode = findJavaBeanFrombeanList(beanClass,
- (JavaBeanList) targetNode.getParent(), mappingList , true);
+ (JavaBeanList) targetNode.getParent(), mappingList,
+ true);
if (childSourceNode == null) {
throw new RuntimeException("Can't find the class "
+ beanClass);
@@ -240,19 +257,24 @@
mapping = new MappingModel(childTargetNode, childSourceNode);
} else {
mapping = new MappingModel(childSourceNode, childTargetNode);
+ SelectorAttributes selectorAttributes = UIUtils
+ .guessSelectorProperty(selector, childSourceNode);
+ mapping.getProperties().add(
+ new PropertyModel(PRO_SELECTOR_ATTRIBUTES,
+ selectorAttributes));
}
UIUtils.assignBindingPropertyToMappingModel(binding, mapping,
new Object[] { SmooksModelUtils.ATTRIBUTE_PROPERTY,
SmooksModelUtils.ATTRIBUTE_SELECTOR });
PropertyModel bindingProperty = new PropertyModel();
- bindingProperty.setName(BINDING_TYPE);
+ bindingProperty.setName(PRO_BINDING_TYPE);
if (!isReferenceBinding) {
bindingProperty.setValue(PROPERTY_BINDING);
} else {
bindingProperty.setValue(REFERENCE_BINDING);
}
mapping.getProperties().add(
- new PropertyModel(REFERENCE_RESOURCE_CONFIG,
+ new PropertyModel(PRO_REFERENCE_RESOURCE_CONFIG,
resourceConfig));
mapping.getProperties().add(bindingProperty);
mappingList.getMappingModelList().add(mapping);
@@ -331,7 +353,7 @@
MappingModel mappingModel = (MappingModel) iterator.next();
if (mappingModel.getTarget() == javaBean) {
if (BEAN_CREATION.equals(mappingModel
- .getPropertyValue(BINDING_TYPE))) {
+ .getPropertyValue(PRO_BINDING_TYPE))) {
return true;
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanPropertiesSection.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanPropertiesSection.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanPropertiesSection.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -97,7 +97,7 @@
controlComposite.setLayout(gl);
factory.createLabel(controlComposite, Messages
- .getString("JavaBeanPropertiesSection.TargetInstanceClass"));
//$NON-NLS-1$
+ .getString("JavaBeanPropertiesSection.TargetInstanceClass")).setVisible(false);
//$NON-NLS-1$
instanceClassComposite = factory.createComposite(controlComposite);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -110,6 +110,7 @@
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
instanceClassText.setLayoutData(gd);
+ instanceClassComposite.setVisible(false);
Button button1 = factory.createButton(instanceClassComposite, Messages
.getString("JavaBeanPropertiesSection.Browse"), //$NON-NLS-1$
@@ -231,6 +232,7 @@
.getString("JavaBeanPropertiesSection.ErrorMessageTitle"),
Messages.getString("JavaBeanPropertiesSection.TypeDialogErrorMessage"));
//$NON-NLS-1$ //$NON-NLS-2$
return;
}
+ // TODO should modify the scope to inculde the required projects
IJavaSearchScope scope = JavaSearchScopeFactory.getInstance()
.createJavaProjectSearchScope(javaProject, true);
SelectionDialog dialog;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -50,7 +50,7 @@
} catch (JavaModelException e) {
if (viewer instanceof PropertyChangeListener) {
beanList
- .addPropertyChangeListener((PropertyChangeListener) viewer);
+ .addNodePropetyChangeListener((PropertyChangeListener) viewer);
}
throw new InvocationTargetException(e);
}
@@ -87,7 +87,7 @@
}
}
if (viewer instanceof PropertyChangeListener) {
- beanList.addPropertyChangeListener((PropertyChangeListener) viewer);
+ beanList.addNodePropetyChangeListener((PropertyChangeListener) viewer);
}
return beanList;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -94,7 +94,7 @@
private void registeListener(Object listener, JavaBeanModel javaBean) {
if (listener instanceof PropertyChangeListener) {
javaBean
- .addPropertyChangeListener((PropertyChangeListener) listener);
+ .addNodePropetyChangeListener((PropertyChangeListener) listener);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -34,6 +34,17 @@
SmooksConfigurationFileGenerateContext context = getSmooksContext();
if(context == null) return;
+ List elements = ((IStructuredSelection) selection).toList();
+ for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
+ JavaBeanModel model = (JavaBeanModel) iterator.next();
+ AbstractStructuredDataModel graphModel = UIUtils.findGraphModel(
+ context.getGraphicalRootModel(), model);
+ if(graphModel instanceof SourceModel){
+ setEnabled(false);
+ break;
+ }
+ }
+
NewJavaBeanStrucutredDataWizard wizard = new NewJavaBeanStrucutredDataWizard();
IProject project = context.getSmooksConfigFile().getProject();
IJavaProject javaProject = null;
@@ -52,14 +63,14 @@
Object input = viewer.getInput();
if(input == null){
if(viewer instanceof PropertyChangeListener){
- list.addPropertyChangeListener((PropertyChangeListener)viewer);
+ list.addNodePropetyChangeListener((PropertyChangeListener)viewer);
}
viewer.setInput(list);
}else{
if(input instanceof JavaBeanList){
List children = list.getChildren();
if(viewer instanceof PropertyChangeListener){
- ((JavaBeanList)input).addPropertyChangeListener((PropertyChangeListener)viewer);
+ ((JavaBeanList)input).addNodePropetyChangeListener((PropertyChangeListener)viewer);
}
for (Iterator iterator = children.iterator(); iterator
.hasNext();) {
@@ -77,7 +88,9 @@
super.setSelection(selection);
setEnabled(true);
SmooksConfigurationFileGenerateContext context = getSmooksContext();
- if(context == null) return;
+ if(context == null){
+ return;
+ }
List elements = ((IStructuredSelection) selection).toList();
for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
JavaBeanModel model = (JavaBeanModel) iterator.next();
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -43,7 +43,7 @@
// disConnectAllConnections(graphModel);
}
if(viewer instanceof PropertyChangeListener){
- model.removePropertyChangeListener((PropertyChangeListener)viewer);
+ model.removeNodePropetyChangeListener((PropertyChangeListener)viewer);
}
beanList.removeJavaBean(model);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/CompositeSelectionProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/CompositeSelectionProvider.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/CompositeSelectionProvider.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -63,6 +63,10 @@
*/
public void setSelection(ISelection selection) {
this.selection = selection;
+// for (Iterator iterator = this.list.iterator(); iterator.hasNext();) {
+// ISelectionProvider provider = (ISelectionProvider) iterator.next();
+// provider.setSelection(selection);
+// }
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -344,6 +344,9 @@
@Override
protected void pageChange(int newPageIndex) {
int oldPageIndex = this.getCurrentPage();
+ if(oldPageIndex == 0){
+ graphicalPage.fireEmptySelection();
+ }
if (oldPageIndex == -1 || oldPageIndex == newPageIndex) {
super.pageChange(newPageIndex);
return;
@@ -353,9 +356,9 @@
super.pageChange(newPageIndex);
return;
}
-
ByteArrayOutputStream tempStream = null;
XMLWriter writer = null;
+
try {
if ((oldPageIndex == 0 || oldPageIndex == 1) && newPageIndex == 2) {
if (xmlTextEditor.getErrorMessage() == null) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.smooks.ui.editors;
+import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
@@ -63,6 +64,7 @@
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
@@ -114,7 +116,6 @@
import org.jboss.tools.smooks.analyzer.MappingModel;
import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
import org.jboss.tools.smooks.analyzer.ResolveCommand;
-import org.jboss.tools.smooks.analyzer.ResourceConfigEraser;
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.analyzer.SmooksFileBuilder;
import org.jboss.tools.smooks.graphical.GraphInformations;
@@ -123,7 +124,6 @@
import org.jboss.tools.smooks.graphical.Params;
import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
import org.jboss.tools.smooks.model.DocumentRoot;
-import org.jboss.tools.smooks.model.SmooksFactory;
import org.jboss.tools.smooks.model.SmooksResourceListType;
import org.jboss.tools.smooks.model.util.SmooksModelConstants;
import org.jboss.tools.smooks.model.util.SmooksResourceFactoryImpl;
@@ -155,13 +155,14 @@
import org.jboss.tools.smooks.ui.wizards.TransformDataSelectionWizard;
import org.jboss.tools.smooks.utils.SmooksGraphConstants;
import org.jboss.tools.smooks.utils.UIUtils;
+import org.jboss.tools.smooks.xml.model.ITransformTreeNode;
/**
* @author Dart Peng
* @Date Jul 28, 2008
*/
public class SmooksGraphicalFormPage extends FormPage implements
- ISelectionChangedListener, ISelectionProvider,
+ ISelectionChangedListener,
org.eclipse.emf.common.command.CommandStackListener, ISaveListener {
private HashMap<Object, Object> graph_trasform_data_map = new HashMap<Object,
Object>();
@@ -237,17 +238,9 @@
return selection;
}
- public void setSelection(ISelection selection) {
- if (this.selection == selection)
- return;
- this.selection = selection;
- SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
- for (Iterator iterator = selectionChangeListener.iterator(); iterator
- .hasNext();) {
- ISelectionChangedListener listener = (ISelectionChangedListener) iterator
- .next();
- listener.selectionChanged(event);
- }
+ public void fireEmptySelection() {
+ StructuredSelection selection = new StructuredSelection(new Object[] {});
+ compositeSelectionProvider.setSelection(selection);
}
public SmooksGraphicalFormPage(FormEditor editor, String id, String title) {
@@ -515,12 +508,12 @@
new Transfer[] { TemplateTransfer.getInstance() },
new TargetTreeDropTargetListener(targetViewer,
getGraphicalViewer()));
-
+
targetViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY
| DND.DROP_LINK, new Transfer[] { TemplateTransfer
.getInstance() }, new TargetTreeDragListener(targetViewer,
getGraphicalViewer()));
-
+
targetViewer.getTree().addPaintListener(new TreePaintControlListener());
targetViewer.getTree().addListener(SWT.PaintItem,
new TreeItemPaintListener());
@@ -640,6 +633,11 @@
protected void initTargetTreeViewer() {
if (this.targetTreeViewerInputModel != null) {
+// if (targetTreeViewerInputModel instanceof ITransformTreeNode
+// && targetViewer instanceof PropertyChangeListener) {
+// ((ITransformTreeNode) targetTreeViewerInputModel)
+// .addNodePropetyChangeListener((PropertyChangeListener) targetViewer);
+// }
targetViewer.setInput(targetTreeViewerInputModel);
}
}
@@ -660,6 +658,11 @@
protected void initSourceTreeViewer() {
if (this.sourceTreeViewerInputModel != null) {
+ if (sourceTreeViewerInputModel instanceof ITransformTreeNode
+ && sourceViewer instanceof PropertyChangeListener) {
+ ((ITransformTreeNode) sourceTreeViewerInputModel)
+ .addNodePropetyChangeListener((PropertyChangeListener) sourceViewer);
+ }
sourceViewer.setInput(sourceTreeViewerInputModel);
}
}
@@ -1042,6 +1045,7 @@
context.setDataMappingRootModel(this.rootModel);
context.setSmooksConfigFile(((IFileEditorInput) getEditorInput())
.getFile());
+ context.setSmooksGraphcalPage(this);
context.setGefDomain(getEditDomain());
List contents = this.smooksResource.getContents();
if (contents.size() > 0) {
@@ -1480,7 +1484,8 @@
}
}
if (UIUtils.setTheProvidersForTreeViewer(viewer, typeID)) {
- viewer.setInput(cw.getTreeViewerInputContents());
+ Object obj = cw.getTreeViewerInputContents();
+ viewer.setInput(obj);
try {
if (viewer == this.sourceViewer) {
this.createSourceGraphModels();
@@ -1688,7 +1693,9 @@
public void selectionChanged(SelectionChangedEvent event) {
this.selection = event.getSelection();
- compositeSelectionProvider.setSelection(selection);
+ if (compositeSelectionProvider != null) {
+ compositeSelectionProvider.setSelection(selection);
+ }
updateSelectionActions();
updataViewerAction(event);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TransformDataTreeViewer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TransformDataTreeViewer.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TransformDataTreeViewer.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -11,6 +11,8 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.jboss.tools.smooks.ui.IXMLStructuredObject;
+import org.jboss.tools.smooks.xml.model.ITransformTreeNode;
/**
* @author Dart
@@ -32,6 +34,18 @@
super(parent, style);
this.editor = editor;
}
+
+ public void inputChanged(Object newInput,Object oldInput){
+ super.inputChanged(newInput, oldInput);
+ if(newInput == oldInput) return;
+ if(newInput != null && newInput instanceof ITransformTreeNode){
+ ((ITransformTreeNode)newInput).addNodePropetyChangeListener(this);
+ }
+ if(oldInput != null && oldInput instanceof ITransformTreeNode){
+ ((ITransformTreeNode)oldInput).removeNodePropetyChangeListener(this);
+ }
+ }
+
public TransformDataTreeViewer(Composite parent,
SmooksGraphicalFormPage editor) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -177,6 +177,7 @@
wizard.addSourceWizardPage(p);
p.setWizard(rootWizard);
}
+ sourceDataCreationWizard = sourceWizard;
}
if (targetWizard != null) {
@@ -187,10 +188,9 @@
wizard.addTargetWizardPage(p);
p.setWizard(rootWizard);
}
+ targetDataCreationWizard = targetWizard;
}
}
- sourceDataCreationWizard = sourceWizard;
- targetDataCreationWizard = targetWizard;
}
private boolean wizardIsCreated(IWizard wizard) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -266,14 +266,21 @@
public void propertyChange(PropertyChangeEvent evt) {
String pm = evt.getPropertyName();
- if (AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_CHANGE
- .equals(pm)) {
- IGraphicalModelListener listener = GraphicalModelListenerManager
- .getInstance().getPaintListener(getSourceDataTypeID(),
- getTargetDataTypeID());
- if (listener == null)
- return;
- listener.modelChanged(getModel(), getSmooksContext(),evt);
+ String sid = getSourceDataTypeID();
+ String tid = getTargetDataTypeID();
+ IGraphicalModelListener listener = GraphicalModelListenerManager
+ .getInstance().getPaintListener(sid, tid);
+ if (listener != null) {
+ if (AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_REMOVE
+ .equals(pm)) {
+ }
+ if (AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_ADD
+ .equals(pm)) {
+ }
+ if (AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_UPDATE
+ .equals(pm)) {
+ listener.modelChanged(getModel(), getSmooksContext(), evt);
+ }
}
}
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/AbstractStructuredDataConnectionModel.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -7,14 +7,19 @@
import java.util.Iterator;
import java.util.List;
-public class AbstractStructuredDataConnectionModel implements PropertyChangeListener {
- public static final String CONNECTION_PROPERTY_CHANGE =
"__connection_property_change";
+public class AbstractStructuredDataConnectionModel implements
+ PropertyChangeListener {
+ public static final String CONNECTION_PROPERTY_REMOVE =
"__connection_property_remove";
+
+ public static final String CONNECTION_PROPERTY_UPDATE =
"__connection_property_update";
+
+ public static final String CONNECTION_PROPERTY_ADD =
"__connection_property_add";
protected IConnectableModel source;
protected IConnectableModel target;
protected List<PropertyModel> properties = new ArrayList<PropertyModel>();
-
- private PropertyChangeSupport support =new PropertyChangeSupport(this);
-
+
+ private PropertyChangeSupport support = new PropertyChangeSupport(this);
+
public AbstractStructuredDataConnectionModel(IConnectableModel source,
IConnectableModel target) {
this();
@@ -23,38 +28,38 @@
attachSource();
attachTarget();
}
-
- public void updateAndAddProperty(String propertyName,Object value){
+
+ // public void updateAndAddProperty(String propertyName,Object value){
+ // for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
+ // PropertyModel property = (PropertyModel) iterator.next();
+ // if(property.getName().equals(propertyName)){
+ // property.setValue(value);
+ // return;
+ // }
+ // }
+ //
+ // PropertyModel model = new PropertyModel(propertyName,value);
+ // properties.add(model);
+ // }
+
+ public Object getProperty(String propertyName) {
for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
PropertyModel property = (PropertyModel) iterator.next();
- if(property.getName().equals(propertyName)){
- property.setValue(value);
- return;
- }
- }
-
- PropertyModel model = new PropertyModel(propertyName,value);
- properties.add(model);
- }
-
- public Object getProperty(String propertyName){
- for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
- PropertyModel property = (PropertyModel) iterator.next();
- if(property.getName().equals(propertyName)){
+ if (property.getName().equals(propertyName)) {
return property.getValue();
}
}
return null;
}
-
- public AbstractStructuredDataConnectionModel(){
+
+ public AbstractStructuredDataConnectionModel() {
}
-
- public void addPropertyChangeListener(PropertyChangeListener listener){
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
support.addPropertyChangeListener(listener);
}
-
- public void removePropertyChangeListener(PropertyChangeListener listener){
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
support.removePropertyChangeListener(listener);
}
@@ -97,9 +102,9 @@
public void setTarget(IConnectableModel target) {
this.target = target;
}
-
- public Object[] getPropertyArray(){
- return properties.toArray();
+
+ public Object[] getPropertyArray() {
+ return properties.toArray();
}
public List<PropertyModel> getProperties() {
@@ -110,47 +115,55 @@
this.properties = properties;
}
- public void addPropertyModel(PropertyModel property){
- if(properties != null){
+ public void addPropertyModel(String name,Object value){
+ addPropertyModel(new PropertyModel(name,value));
+ }
+
+ public void addPropertyModel(PropertyModel property) {
+ if (properties != null) {
boolean updated = false;
for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
PropertyModel p = (PropertyModel) iterator.next();
- if(p.getName().equals(property.getName())){
+ if (p.getName().equals(property.getName())) {
p.setValue(property.getValue());
updated = true;
}
}
- if(!updated){
+ if (!updated) {
this.getProperties().add(property);
property.addPropertyChangeListener(this);
+ support.firePropertyChange(CONNECTION_PROPERTY_ADD, null,
+ property);
+ return;
}
- support.firePropertyChange(CONNECTION_PROPERTY_CHANGE, null, property);
+ support.firePropertyChange(CONNECTION_PROPERTY_UPDATE, null,
+ property);
}
}
-
- public void removePropertyModel(String propertyName){
- List<PropertyModel> list= this.getProperties();
- for (Iterator<PropertyModel> iterator = list.iterator(); iterator.hasNext();) {
+
+ public void removePropertyModel(String propertyName) {
+ List<PropertyModel> list = this.getProperties();
+ for (Iterator<PropertyModel> iterator = list.iterator(); iterator
+ .hasNext();) {
PropertyModel propertyModel = (PropertyModel) iterator.next();
- if(propertyModel.getName().equals(propertyName)){
+ if (propertyModel.getName().equals(propertyName)) {
list.remove(propertyModel);
- support.firePropertyChange(CONNECTION_PROPERTY_CHANGE, propertyModel, null);
+ support.firePropertyChange(CONNECTION_PROPERTY_REMOVE,
+ propertyModel, null);
break;
}
}
-
+
}
-
- public void removePropertyModel(PropertyModel property){
+
+ public void removePropertyModel(PropertyModel property) {
property.removePropertyChangeListener(this);
this.getProperties().remove(property);
- support.firePropertyChange(CONNECTION_PROPERTY_CHANGE, property, null);
+ support.firePropertyChange(CONNECTION_PROPERTY_REMOVE, property, null);
}
public void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
- if(CONNECTION_PROPERTY_CHANGE.equals(name)){
- support.firePropertyChange(evt);
- }
+ support.firePropertyChange(evt);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/model/PropertyModel.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -35,7 +35,7 @@
String oldName = this.name;
this.name = name;
firePropertyChange(
- AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_CHANGE,
+ AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_REMOVE,
oldName, this.name);
}
@@ -76,7 +76,7 @@
Object oldValue = this.value;
this.value = value;
firePropertyChange(
- AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_CHANGE,
+ AbstractStructuredDataConnectionModel.CONNECTION_PROPERTY_REMOVE,
oldValue, this.value);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -24,6 +24,7 @@
import org.eclipse.swt.widgets.Shell;
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.ui.editors.SmooksGraphicalFormPage;
import org.jboss.tools.smooks.ui.gef.model.GraphRootModel;
/**
@@ -40,9 +41,17 @@
private Properties properties = new Properties();
protected IFile smooksConfigFile = null;
protected EditingDomain domain;
+ protected SmooksGraphicalFormPage smooksGraphcalPage = null;
+ protected EditDomain gefDomain;
- protected EditDomain gefDomain;
+ public SmooksGraphicalFormPage getSmooksGraphcalPage() {
+ return smooksGraphcalPage;
+ }
+ public void setSmooksGraphcalPage(SmooksGraphicalFormPage smooksGraphcalPage) {
+ this.smooksGraphcalPage = smooksGraphcalPage;
+ }
+
public EditDomain getGefDomain() {
return gefDomain;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -35,6 +35,8 @@
import org.jboss.tools.smooks.javabean.analyzer.JavaModelConnectionResolveCommand;
import org.jboss.tools.smooks.javabean.analyzer.JavaModelResolveCommand;
import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.javabean.model.SelectorAttributes;
+import org.jboss.tools.smooks.javabean.ui.BeanPopulatorMappingAnalyzer;
import org.jboss.tools.smooks.model.AbstractResourceConfig;
import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.SmooksPackage;
@@ -79,6 +81,40 @@
obj);
addResourceConfigCommand.execute();
}
+
+ public static SelectorAttributes guessSelectorProperty(String
selector,IXMLStructuredObject node){
+ SelectorAttributes property = new SelectorAttributes();
+ if(selector != null) selector.trim();
+ boolean hasSperator = false;
+ for (int i = 0; i < BeanPopulatorMappingAnalyzer.SELECTOR_SPERATORS.length; i++) {
+ if(selector.indexOf(BeanPopulatorMappingAnalyzer.SELECTOR_SPERATORS[i]) != -1){
+ property.setSelectorSperator(BeanPopulatorMappingAnalyzer.SELECTOR_SPERATORS[i]);
+ hasSperator = true;
+ break;
+ }
+ }
+
+ if(!hasSperator){
+ property.setSelectorPolicy(BeanPopulatorMappingAnalyzer.ONLY_NAME);
+ return property;
+ }
+ String[] nodeNames = selector.split(property.getSelectorSperator());
+ IXMLStructuredObject parent = node;
+ for(int i = 1 ; i < nodeNames.length ; i++){
+ parent = parent.getParent();
+ }
+ IXMLStructuredObject rootNode = getRootParent(node);
+ if(parent == rootNode){
+ property.setSelectorPolicy(BeanPopulatorMappingAnalyzer.FULL_PATH);
+ return property;
+ }
+ if(parent == node.getParent()){
+ property.setSelectorPolicy(BeanPopulatorMappingAnalyzer.INCLUDE_PARENT);
+ }else{
+ property.setSelectorPolicy(BeanPopulatorMappingAnalyzer.IGNORE_ROOT);
+ }
+ return property;
+ }
public static AbstractXMLObject getRootTagXMLObject(AbstractXMLObject xmlObj) {
if (xmlObj == null)
@@ -625,6 +661,7 @@
public static IXMLStructuredObject getRootParent(IXMLStructuredObject child) {
IXMLStructuredObject parent = child.getParent();
+ if(child.isRootNode()) return child;
if (parent == null || parent.isRootNode())
return child;
IXMLStructuredObject temp = parent;
@@ -634,26 +671,57 @@
}
return parent;
}
+
+ public static String generatePath(IXMLStructuredObject node,SelectorAttributes
selectorAttributes){
+ String sperator = selectorAttributes.getSelectorSperator();
+ String policy = selectorAttributes.getSelectorPolicy();
+ if(sperator == null) sperator = " ";
+ if(policy == null) policy = BeanPopulatorMappingAnalyzer.FULL_PATH;
+ if(policy.equals(BeanPopulatorMappingAnalyzer.FULL_PATH)){
+ return generateFullPath(node, sperator);
+ }
+ if(policy.equals(BeanPopulatorMappingAnalyzer.INCLUDE_PARENT)){
+ return generatePath(node, node.getParent(),sperator,true);
+ }
+ if(policy.equals(BeanPopulatorMappingAnalyzer.IGNORE_ROOT)){
+
+ }
+ if(policy.equals(BeanPopulatorMappingAnalyzer.ONLY_NAME)){
+ return node.getNodeName();
+ }
+ return generateFullPath(node,sperator);
+ }
+
+ public static String generateFullPath(IXMLStructuredObject node,final String sperator){
+ return generatePath(node, getRootParent(node), sperator, true);
+ }
public static String generatePath(IXMLStructuredObject startNode,
IXMLStructuredObject stopNode, final String sperator,
boolean includeContext) {
String name = "";
+ if(startNode == stopNode){
+ return startNode.getNodeName();
+ }
List<IXMLStructuredObject> nodeList = new
ArrayList<IXMLStructuredObject>();
IXMLStructuredObject temp = startNode;
if (stopNode != null) {
- while (temp != stopNode && temp != null) {
+ while (temp != stopNode.getParent() && temp != null) {
nodeList.add(temp);
temp = temp.getParent();
}
}
- for (int i =0; i < nodeList.size(); i++) {
+ int length = nodeList.size();
+ if(!includeContext){
+ length--;
+ }
+ for (int i =0; i < length; i++) {
IXMLStructuredObject n = nodeList.get(i);
String nodeName = n.getNodeName();
if(n.isAttribute()){
nodeName = "@" + nodeName;
}
- name = nodeName + sperator + name;
+ name = sperator + nodeName + name;
}
return name;
}
@@ -685,7 +753,20 @@
public static IXMLStructuredObject localXMLNodeWithPath(String path,
IXMLStructuredObject contextNode) {
- return localXMLNodeWithPath(path, contextNode, null, true);
+ if(path == null) return null;
+ path = path.trim();
+ String[] sperators = BeanPopulatorMappingAnalyzer.SELECTOR_SPERATORS;
+ String sperator = null;
+ boolean hasSperator = false;
+ for (int i = 0; i < sperators.length; i++) {
+ sperator = sperators[i];
+ if(path.indexOf(sperator) != -1){
+ hasSperator = true;
+ break;
+ }
+ }
+ if(!hasSperator) sperator = null;
+ return localXMLNodeWithPath(path, contextNode, sperator, true);
}
public static IXMLStructuredObject localXMLNodeWithPath(String path,
@@ -703,6 +784,11 @@
// to find the first node
// first time , we search the node via context
String firstNodeName = pathes[0];
+ int index = 0;
+ while(firstNodeName.length() == 0){
+ index ++;
+ firstNodeName = pathes[index];
+ }
IXMLStructuredObject firstModel = localXMLNodeWithNodeName(
firstNodeName, contextNode);
@@ -720,7 +806,7 @@
return null;
}
}
- for (int i = 1; i < pathes.length; i++) {
+ for (int i = index + 1; i < pathes.length; i++) {
firstModel = getChildNodeWithName(pathes[i], firstModel);
if (firstModel == null && throwException) {
throw new RuntimeException("Can't find the node : "
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -22,7 +22,7 @@
* @author Dart Peng
* @Date Jul 25, 2008
*/
-public class AbstractXMLObject implements IXMLNode , IXMLStructuredObject{
+public class AbstractXMLObject implements ITransformTreeNode , IXMLStructuredObject{
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
Copied:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java
(from rev 13075,
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/IXMLNode.java)
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -0,0 +1,17 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml.model;
+
+import java.beans.PropertyChangeListener;
+
+/**
+ * @author Dart
+ *
+ */
+public interface ITransformTreeNode {
+
+ public void addNodePropetyChangeListener(PropertyChangeListener listener);
+
+ public void removeNodePropetyChangeListener(PropertyChangeListener listener);
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/IXMLNode.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/IXMLNode.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/IXMLNode.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -1,17 +0,0 @@
-/**
- *
- */
-package org.jboss.tools.smooks.xml.model;
-
-import java.beans.PropertyChangeListener;
-
-/**
- * @author Dart
- *
- */
-public interface IXMLNode {
-
- public void addNodePropetyChangeListener(PropertyChangeListener listener);
-
- public void removeNodePropetyChangeListener(PropertyChangeListener listener);
-}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLPropertiesSection.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLPropertiesSection.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLPropertiesSection.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -99,7 +99,7 @@
namespaceText.setLayoutData(gd);
namespaceText.setEditable(false);
- factory.createLabel(com, "Connection Type : ");
+ factory.createLabel(com, "Connection Type : ").setVisible(false);
connectionTypeCombo = factory.createCCombo(com);// (com, "");
connectionTypeCombo.add("mapping");
connectionTypeCombo.add("binding");
@@ -115,6 +115,7 @@
}
});
+ connectionTypeCombo.setVisible(false);
}
private void setConnectionType() {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java 2009-01-20
00:38:11 UTC (rev 13134)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java 2009-01-20
07:09:55 UTC (rev 13135)
@@ -15,7 +15,6 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.smooks.graphical.GraphInformations;
import org.jboss.tools.smooks.model.SmooksResourceListType;
-import org.jboss.tools.smooks.utils.UIUtils;
/**
* @author Dart Peng<br>
@@ -31,7 +30,6 @@
public Object buildSourceInputObjects(GraphInformations graphInfo,
SmooksResourceListType listType, IFile sourceFile , Object viewer)
throws InvocationTargetException {
- UIUtils.checkSelector(listType);
return super.buildSourceInputObjects(graphInfo, listType, sourceFile,viewer);
}
}