Commit 074c466d authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

bugfix: parent and field wasn't correctly setted

parent 9aaaee4a
......@@ -87,6 +87,7 @@ public class DefaultObjectIntrospector {
Class fieldType = innerField.getType();
Object fieldValue = innerField.get(objectComplex.getValue());
OhObject child = introspectChild(ohOui, fieldType, fieldName, fieldValue, innerField.getGenericType(), fieldFilters);
child.setField(innerField);
if (innerField.isAnnotationPresent(Description.class)) {
child.setName(innerField.getAnnotation(Description.class).name());
child.setDescription(innerField.getAnnotation(Description.class).longDescription().trim());
......
......@@ -2,6 +2,7 @@ package fr.cemagref.ohoui.structure;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.logging.Logger;
public class OhObject<T> {
......@@ -49,7 +50,9 @@ public class OhObject<T> {
public void setValue(T value) throws IllegalArgumentException, IllegalAccessException {
this.value = value;
if (parent != null) {
field.set(parent, value);
field.set(parent.getValue(), value);
} else {
Logger.getLogger(OhObject.class.getName()).warning("Parent not present for object: " + this.name);
}
}
......@@ -72,4 +75,13 @@ public class OhObject<T> {
public boolean isFinal() {
return Modifier.isFinal(field.getModifiers());
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(getName());
buf.append(" (").append(getDeclaredType());
buf.append(") = ").append(getValue());
return buf.toString();
}
}
......@@ -34,6 +34,7 @@ public class OhObjectComplex<T> extends OhObject<T> implements Iterable<OhObject
}
public boolean addChild(OhObject e) {
e.setParent(this);
return children.add(e);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment