Bug 425326 - Support of Read only property in bean model
diff --git a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/AbstractMetaclass.java b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/AbstractMetaclass.java
index 2e37737..3bb21a8 100644
--- a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/AbstractMetaclass.java
+++ b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/AbstractMetaclass.java
@@ -228,23 +228,28 @@
property = superClass.findProperty(name);
}
if (property == null) {
+ Method getter = null;
+ Method setter = null;
+ Class<?> propertyType = null;
try {
- Method getter = DynamicProperty.createGetter(type, name);
- if (getter == null) {
- return null;
- }
- Class<?> propertyType = getter.getReturnType();
- if (shouldIgnored(getter.getDeclaringClass(), name,
- propertyType)) {
- return null;
- }
- Method setter = DynamicProperty.createSetter(type,
- propertyType, name);
- return new DynamicProperty(propertyType, setter, getter, name);
+ getter = DynamicProperty.createGetter(type, name);
} catch (NoSuchMethodException e) {
+ }
+ if (getter == null) {
return null;
}
+ propertyType = getter.getReturnType();
+ if (shouldIgnored(getter.getDeclaringClass(), name, propertyType)) {
+ return null;
+ }
+ try {
+ setter = DynamicProperty.createSetter(type, propertyType, name);
+ } catch (NoSuchMethodException e) {
+ }
+ if (getter != null) {
+ return new DynamicProperty(propertyType, setter, getter, name);
+ }
}
return property;
}
diff --git a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/AbstractProperty.java b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/AbstractProperty.java
index 8f1befa..d1d6449 100644
--- a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/AbstractProperty.java
+++ b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/AbstractProperty.java
@@ -64,7 +64,7 @@
}
public boolean isReadOnly() {
- return true;
+ return false;
}
/*
diff --git a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/BeanProperty.java b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/BeanProperty.java
index 45a6eee..a42ebf1 100644
--- a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/BeanProperty.java
+++ b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/BeanProperty.java
@@ -134,7 +134,7 @@
return containment;
}
- public boolean isReadOnly() {
+ public boolean isReadOnly(Object target, Object value) {
return descriptor.getWriteMethod() == null;
}
}
diff --git a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/DynamicProperty.java b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/DynamicProperty.java
index d925db6..ba1c3eb 100644
--- a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/DynamicProperty.java
+++ b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/DynamicProperty.java
@@ -62,6 +62,11 @@
return null;
}
+ @Override
+ public boolean isReadOnly() {
+ return this.setter == null;
+ }
+
public static Method createSetter(Class<?> type, Class<?> propertyType, String name) throws SecurityException, NoSuchMethodException {
return type.getMethod("set" + Character.toUpperCase(name.charAt(0)) + name.substring(1), propertyType);
}
diff --git a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/FieldProperty.java b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/FieldProperty.java
index 9bc17a5..bf8d0e7 100644
--- a/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/FieldProperty.java
+++ b/org.eclipse.xwt/src/org/eclipse/xwt/javabean/metadata/properties/FieldProperty.java
@@ -49,7 +49,7 @@
if (value != null) {
Class<?> fieldType = field.getType();
Class<?> valueType = value.getClass();
- if (!ObjectUtil.isAssignableFrom(fieldType, value.getClass())) {
+ if (!ObjectUtil.isAssignableFrom(fieldType, valueType)) {
IConverter converter = XWT.findConvertor(valueType, fieldType);
if (converter != null) {
value = converter.convert(value);