Object fieldValue = null;
try {
fieldValue = field.get(bean);
} catch (Exception e) {
ParserPlugin.getLogger().error(e);
throw new ParserException(e);
}
JComponent fieldComponent = (JComponent) fieldValue;
WidgetAdapter adapter = ExtensionRegistry.createWidgetAdapter(fieldComponent, true);
if (adapter.getWidget() != fieldComponent && fieldComponent instanceof JPopupMenu && adapter.getWidget() instanceof JPopupMenu) {
JComponent jcomp = findPopupInvoker((JPopupMenu) fieldComponent, bean);
if (jcomp != null) {
jcomp.setComponentPopupMenu((JPopupMenu) adapter.getWidget());
}
}
adapter.setName(fieldName);
adapter.setLastName(fieldName);
int flags = field.getModifiers();
setAdapterFieldAccess(adapter, flags);
String getName = NamespaceUtil.getGetMethodName(fieldName);
Method getMethod = null;
try {
getMethod = clazz.getDeclaredMethod(getName);
} catch (NoSuchMethodException nsme) {
getName = NamespaceUtil.getGetMethodName(cunit, fieldName);
if (getName == null)
throw new ParserException("Method " + NamespaceUtil.getGetMethodName(fieldName) + "() is not found!\n" + "Please define it to initialize " + fieldName);
try {
getMethod = clazz.getDeclaredMethod(getName);
WidgetAdapter ba = WidgetAdapter.getWidgetAdapter(fieldComponent);
ba.setProperty("getMethodName", getName);
} catch (NoSuchMethodException e) {
throw new ParserException("Method " + getName + "() is not found!\n" + "Please define it to initialize " + fieldName);
}
}
flags = getMethod.getModifiers();
setAdapterGetMethodAccess(adapter, flags);