use of com.servoy.j2db.server.headlessclient.dataui.WebImageBeanHolder in project servoy-client by Servoy.
the class WebForm method registerComponentsToScope.
private int registerComponentsToScope(Scriptable fs, ElementScope es, int counter, Object[] comps, Map<String, Object[]> hmChildrenJavaMembers, Object parent) {
if (comps != null) {
for (Object comp : comps) {
if (comp instanceof WebCellBasedView) {
WebCellBasedView portal = (WebCellBasedView) comp;
counter = registerComponentsToScope(fs, es, counter, portal.getComponents(), hmChildrenJavaMembers, comp);
}
String name = null;
if (comp instanceof WrapperContainer) {
comp = ((WrapperContainer) comp).getDelegate();
}
if (comp instanceof IComponent) {
name = ((IComponent) comp).getName();
} else if (comp instanceof java.awt.Component) {
name = ((java.awt.Component) comp).getName();
}
if (comp instanceof WebImageBeanHolder) {
comp = ((WebImageBeanHolder) comp).getDelegate();
} else if (comp instanceof WebBeanHolder) {
comp = ((WebBeanHolder) comp).getDelegate();
}
String groupName = FormElementGroup.getName((String) formController.getComponentProperty(comp, ComponentFactory.GROUPID_COMPONENT_PROPERTY));
Object scriptable = comp;
if (comp instanceof IScriptableProvider)
scriptable = ((IScriptableProvider) comp).getScriptObject();
JavaMembers jm = ScriptObjectRegistry.getJavaMembers(scriptable.getClass(), ScriptableObject.getTopLevelScope(fs));
// $NON-NLS-1$
boolean named = name != null && !name.equals("") && !name.startsWith(ComponentFactory.WEB_ID_PREFIX);
if (groupName != null || named) {
try {
Scriptable s;
if (parent instanceof WebCellBasedView) {
s = new CellNativeJavaObject(fs, comp, jm, (WebCellBasedView) parent);
} else {
s = new NativeJavaObject(fs, scriptable, jm);
}
if (named) {
es.put(name, fs, s);
es.put(counter++, fs, s);
hmChildrenJavaMembers.put(name, new Object[] { jm, scriptable });
}
if (groupName != null) {
Object group = es.get(groupName, fs);
if (group == Scriptable.NOT_FOUND) {
group = new NativeJavaObject(fs, new RuntimeGroup(groupName), ScriptObjectRegistry.getJavaMembers(RuntimeGroup.class, ScriptableObject.getTopLevelScope(fs)));
es.put(groupName, fs, group);
es.put(counter++, fs, group);
}
if (scriptable instanceof IRuntimeComponent && group instanceof NativeJavaObject && ((NativeJavaObject) group).unwrap() instanceof RuntimeGroup) {
((RuntimeGroup) (((NativeJavaObject) group).unwrap())).addScriptBaseMethodsObj((IRuntimeComponent) scriptable);
}
}
} catch (Throwable ex) {
// incase classdefnot founds are thrown for beans,applets/plugins
Debug.error(ex);
}
}
}
}
return counter;
}
Aggregations