use of com.servoy.j2db.IServoyBeanFactory in project servoy-client by Servoy.
the class ComponentFactory method createBean.
protected static IComponent createBean(IApplication application, Form form, Bean bean, FlattenedSolution flattenedSolution) {
IComponent c = null;
try {
Object obj = getBeanInstanceFromXML(application, bean.getBeanClassName(), bean.getBeanXML());
if (flattenedSolution != null && obj != null) {
obj = flattenedSolution.setBeanDesignInstance(bean, obj);
}
if (obj instanceof Component) {
((Component) obj).setName(bean.getName());
} else if (obj instanceof IComponent) {
((IComponent) obj).setName(bean.getName());
}
if (obj instanceof IServoyAwareBean) {
((IServoyAwareBean) obj).initialize((IClientPluginAccess) application.getPluginAccess());
}
if (obj instanceof IServoyBeanFactory) {
testReturnTypesForBean(application, obj);
obj = ((IServoyBeanFactory) obj).getBeanInstance(application.getApplicationType(), (IClientPluginAccess) application.getPluginAccess(), new Object[] { ComponentFactory.getWebID(form, bean), form.getName(), form.getStyleName() });
}
testReturnTypesForBean(application, obj);
if (obj instanceof Applet) {
((FormManager) application.getFormManager()).initializeApplet((Applet) obj, bean.getSize());
}
if (obj == null) {
c = application.getItemFactory().createLabel(ComponentFactory.getWebID(form, bean), "bean missing " + bean.getBeanClassName());
} else if (!(obj instanceof java.awt.Component) && !(obj instanceof IComponent)) {
c = application.getItemFactory().createInvisibleBean(ComponentFactory.getWebID(form, bean), obj);
} else if (!(obj instanceof IComponent)) {
c = application.getItemFactory().createBeanHolder(ComponentFactory.getWebID(form, bean), (Component) obj, bean.getAnchors());
} else {
c = (IComponent) obj;
}
// beans do not store the transparent property, keep the value from component
boolean isOpaque = c.isOpaque();
applyBasicComponentProperties(application, c, bean, null);
c.setOpaque(isOpaque);
} catch (// sometimes setting size or location throws exception or even error...create label instead
Throwable e) {
Debug.error(e);
c = application.getItemFactory().createLabel(bean.getName(), "error acessing bean" + bean.getBeanClassName());
java.awt.Dimension dim = bean.getSize();
if (dim != null)
c.setSize(bean.getSize());
}
return c;
}
Aggregations