Author: DartPeng
Date: 2010-01-06 05:15:31 -0500 (Wed, 06 Jan 2010)
New Revision: 19660
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java
Log:
JBIDE-5605
Fixed
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java 2010-01-06
07:59:28 UTC (rev 19659)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java 2010-01-06
10:15:31 UTC (rev 19660)
@@ -84,7 +84,14 @@
if (m instanceof FreemarkerTemplateXMLModel) {
if (data instanceof EObject) {
if (SmooksUIUtils.isCollectionJavaGraphModel((EObject) data)) {
- return ((FreemarkerTemplateXMLModel) m).isManyOccurs();
+ boolean flag = ((FreemarkerTemplateXMLModel) m).isManyOccurs()
+ && gm.getTargetConnections().isEmpty();
+ Object p =
SmooksFreemarkerTemplateGraphicalEditor.parentIsRequriedCollectionNode(gm);
+ if(p != null) {
+ return false;
+ }else{
+ return flag;
+ }
}
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java 2010-01-06
07:59:28 UTC (rev 19659)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java 2010-01-06
10:15:31 UTC (rev 19660)
@@ -17,6 +17,7 @@
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.gef.EditPartFactory;
+import org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.graphical.editors.ConnectionModelFactory;
@@ -90,23 +91,62 @@
AbstractSmooksGraphicalModel abstractSmooksGraphicalModel =
(AbstractSmooksGraphicalModel) iterator.next();
Object data = abstractSmooksGraphicalModel.getData();
if (data instanceof IFreemarkerTemplateModel) {
- if (((IFreemarkerTemplateModel) data).isRequired() &&
!((IFreemarkerTemplateModel) data).isHidden(root)) {
- if (abstractSmooksGraphicalModel.getTargetConnections().isEmpty()) {
- abstractSmooksGraphicalModel.addMessage("This node must be linked with source
node");
- abstractSmooksGraphicalModel.setSeverity(IValidatableModel.ERROR);
- }
+ AbstractSmooksGraphicalModel requiredCollectionLinkParent =
parentIsRequriedCollectionNode(abstractSmooksGraphicalModel);
+ if(requiredCollectionLinkParent != null){
+ AbstractXMLObject parentNode =
(AbstractXMLObject)requiredCollectionLinkParent.getData();
+ abstractSmooksGraphicalModel.addMessage("Its parent node '" +
parentNode.getName() + "' should be connected first.");
+ abstractSmooksGraphicalModel.setSeverity(IValidatableModel.ERROR);
}
- if (((IFreemarkerTemplateModel) data).isManyOccurs()) {
- if (abstractSmooksGraphicalModel.getTargetConnections().isEmpty()) {
- abstractSmooksGraphicalModel.addMessage("This node must be linked with
collection java node");
- abstractSmooksGraphicalModel.setSeverity(IValidatableModel.ERROR);
- }
+ if (isRequiredNode(abstractSmooksGraphicalModel)) {
+ abstractSmooksGraphicalModel.addMessage("This node must be linked with source
node");
+ abstractSmooksGraphicalModel.setSeverity(IValidatableModel.ERROR);
}
+ if (isRequiredCollectionNode(abstractSmooksGraphicalModel)) {
+ abstractSmooksGraphicalModel.addMessage("This node must be linked with
collection java node");
+ abstractSmooksGraphicalModel.setSeverity(IValidatableModel.ERROR);
+ }
}
validateTemplateContentsModel(type, abstractSmooksGraphicalModel.getChildren());
}
}
+
+ public static AbstractSmooksGraphicalModel
parentIsRequriedCollectionNode(AbstractSmooksGraphicalModel abstractSmooksGraphicalModel)
{
+ AbstractSmooksGraphicalModel parent = abstractSmooksGraphicalModel.getParent();
+ Object data = abstractSmooksGraphicalModel.getData();
+ if (data instanceof IFreemarkerTemplateModel) {
+ if (isRequiredCollectionNode(parent)) {
+ return parent;
+ }
+ return parentIsRequriedCollectionNode(parent);
+ }
+ return null;
+ }
+
+ private boolean isRequiredNode(AbstractSmooksGraphicalModel
abstractSmooksGraphicalModel) {
+ Object data = abstractSmooksGraphicalModel.getData();
+ if (data instanceof IFreemarkerTemplateModel) {
+ if (((IFreemarkerTemplateModel) data).isRequired() &&
!((IFreemarkerTemplateModel) data).isHidden(root)) {
+ if (abstractSmooksGraphicalModel.getTargetConnections().isEmpty()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isRequiredCollectionNode(AbstractSmooksGraphicalModel
abstractSmooksGraphicalModel) {
+ Object data = abstractSmooksGraphicalModel.getData();
+ if (data instanceof IFreemarkerTemplateModel) {
+ if (((IFreemarkerTemplateModel) data).isManyOccurs()) {
+ if (abstractSmooksGraphicalModel.getTargetConnections().isEmpty()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/*
* (non-Javadoc)
*
Show replies by date