DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
// If bean is an array, we want to wrap this in a Superbean's "values"
// field.
if (bean != null && bean.getClass().isArray()) {
try {
BeanCreator c = new BeanCreator(new URLClassLoader(new URL[0],
Thread.currentThread().getContextClassLoader()));
Object superBean = c.defineClass(
"com.subhajit.foo.A"
+ UUID.randomUUID().toString()
.replace('-', 'A') + ".tempClass",
new String[] { "arrayElements" },
new Class<?>[] { bean.getClass() }).newInstance();
BeanUtils.getInstance().set(superBean, "arrayElements", bean);
setupBean(rootNode, superBean, fieldsToEdit);
tree.setModel(new DefaultTreeModel(rootNode));
} catch (javax.management.ReflectionException exc) {
throw new ReflectionException(exc);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e);
} catch (IOException e) {
throw new ReflectionException(e);
} catch (InstantiationException e) {
throw new ReflectionException(e);
} catch (IllegalAccessException e) {
throw new ReflectionException(e);
} catch (IllegalArgumentException e) {
throw new ReflectionException(e);
} catch (NoSuchFieldException e) {
throw new ReflectionException(e);
} catch (NoSuchMethodException e) {
throw new ReflectionException(e);
} catch (InvocationTargetException e) {
throw new ReflectionException(e);
}
} else if (bean != null && List.class.isAssignableFrom(bean.getClass())) {
try {
BeanCreator c = new BeanCreator(new URLClassLoader(new URL[0],
Thread.currentThread().getContextClassLoader()));
Object superBean = c.defineClass(
"com.swa.foo." + UUID.randomUUID().toString()
+ ".tempClass",
new String[] { "arrayElements" },
new Class<?>[] { bean.getClass() }).newInstance();
try {