Author: tfennelly
Date: 2009-12-03 08:43:07 -0500 (Thu, 03 Dec 2009)
New Revision: 19023
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5365
Auto-expanded bean models should have concrete class implementations where a bean property
is an Interface/Abstract
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java 2009-12-03
13:41:45 UTC (rev 19022)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java 2009-12-03
13:43:07 UTC (rev 19023)
@@ -21,8 +21,12 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
import org.jboss.tools.smooks.configuration.editors.uitls.JavaPropertyUtils;
@@ -225,7 +229,7 @@
JavaBeanModel(Class beanClass, String beanName, PropertyDescriptor propertyDescriptor,
Class parentClass,
boolean lazyLoadProperties) {
this.lazyLoadProperties = lazyLoadProperties;
- this.beanClass = beanClass;
+ this.beanClass = toConcreteImpl(beanClass);
this.name = beanName;
if (beanClass == null)
return;
@@ -287,6 +291,23 @@
this(beanClass, null, null, null, lazyLoadProperties);
}
+ private Class<? extends Object> toConcreteImpl(Class declaredType) {
+
+ // Intentionally not doing an isAssignableFrom test... want to know is it the
+ // the exact class...
+ if(declaredType == List.class) {
+ return ArrayList.class;
+ } else if(declaredType == Set.class) {
+ return LinkedHashSet.class;
+ } else if(declaredType == Collection.class) {
+ return ArrayList.class;
+ } else if(declaredType == Map.class) {
+ return LinkedHashMap.class;
+ }
+
+ return declaredType;
+ }
+
public boolean isPrimitive() {
Class<?> beanType = getBeanClass();
if (beanType == null)
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-03
13:41:45 UTC (rev 19022)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-03
13:43:07 UTC (rev 19023)
@@ -115,24 +115,22 @@
((BeanType) parent).setClass(parentBeanModel.getBeanClassString());
if (properties != null && properties.length > 0) {
for (int i = 0; i < properties.length; i++) {
- Object pro = properties[i];
- if (pro instanceof JavaBeanModel && belongsToMe(parentBeanModel,
(JavaBeanModel) pro)) {
- if (((JavaBeanModel) pro).isPrimitive()) {
+ Object beanPropertyObj = properties[i];
+ if (beanPropertyObj instanceof JavaBeanModel && belongsToMe(parentBeanModel,
(JavaBeanModel) beanPropertyObj)) {
+ JavaBeanModel beanProperty = (JavaBeanModel) beanPropertyObj;
+ if (beanProperty.isPrimitive()) {
ValueType value = Javabean12Factory.eINSTANCE.createValueType();
- value.setProperty(((JavaBeanModel) pro).getName());
+ value.setProperty(beanProperty.getName());
((BeanType) parent).getValue().add(value);
} else {
WiringType value = Javabean12Factory.eINSTANCE.createWiringType();
- if (((JavaBeanModel) parentBeanModel).isArray()
- || ((JavaBeanModel) parentBeanModel).isList()) {
-
- } else {
- value.setProperty(((JavaBeanModel) pro).getName());
+ if (!parentBeanModel.isArray() && !parentBeanModel.isList()) {
+ value.setProperty(beanProperty.getName());
}
- String refID = generateBeanID((JavaBeanModel) pro, resourceListType, ids);
+ String refID = generateBeanID(beanProperty, resourceListType, ids);
value.setBeanIdRef(refID);
((BeanType) parent).getWiring().add(value);
- creationObject.addAll(createJavaBeanModel(type, (JavaBeanModel) pro, properties,
+ creationObject.addAll(createJavaBeanModel(type, beanProperty, properties,
resourceListType, ids));
}
}