use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.
the class ContainersScope method findFormComponentContainers.
private static void findFormComponentContainers(Iterator<WebComponent> components, Map<String, List<String>> namesToLayout, FlattenedSolution fs) {
while (components.hasNext()) {
WebComponent component = components.next();
String typeName = (String) component.getProperty(IContentSpecConstants.PROPERTY_TYPENAME);
WebComponentSpecProvider.getInstance();
WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(typeName);
if (spec != null) {
Collection<PropertyDescription> pd = spec.getProperties(FormComponentPropertyType.INSTANCE);
if (pd != null && !pd.isEmpty()) {
PropertyDescription prop = pd.iterator().next();
Object val = component.getProperty(prop.getName());
Form fcomp = FormComponentPropertyType.INSTANCE.getForm(val, fs);
if (fcomp != null && fcomp.isResponsiveLayout()) {
fillNames(fcomp.getLayoutContainers(), namesToLayout, fs);
}
}
}
}
}
use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.
the class ComponentFactory method createComponentEx.
protected static IComponent createComponentEx(IApplication application, Form form, IPersist meta, IDataProviderLookup dataProviderLookup, IScriptExecuter el, boolean printing) {
IComponent comp = null;
switch(meta.getTypeID()) {
case IRepository.FIELDS:
comp = createField(application, form, (Field) meta, dataProviderLookup, el, printing);
break;
case IRepository.GRAPHICALCOMPONENTS:
comp = createGraphicalComponent(application, form, (GraphicalComponent) meta, el, dataProviderLookup);
break;
case IRepository.RECTSHAPES:
comp = createRectangle(application, form, (RectShape) meta);
break;
case IRepository.PORTALS:
comp = createPortal(application, form, (Portal) meta, dataProviderLookup, el, printing);
break;
case IRepository.PARTS:
comp = createPart(application, (Part) meta);
break;
case IRepository.TABPANELS:
TabPanel tabPanelMeta = (TabPanel) meta;
int orient = tabPanelMeta.getTabOrientation();
if (orient == TabPanel.SPLIT_HORIZONTAL || orient == TabPanel.SPLIT_VERTICAL)
comp = createSplitPane(application, form, tabPanelMeta, el);
else
comp = createTabPanel(application, form, tabPanelMeta, el);
break;
case IRepository.BEANS:
comp = createBean(application, form, (Bean) meta, null);
break;
case IRepository.WEBCOMPONENTS:
comp = createWebComponentPlaceholder(application, form, (WebComponent) meta);
break;
default:
Debug.error("ComponentFactory:unkown type " + meta.getTypeID() + ", uuid: " + meta.getUUID() + ", parent:" + meta.getParent());
IStandardLabel label = application.getItemFactory().createLabel(getWebID(form, meta), "ComponentFactory:unkown type " + meta.getTypeID());
label.setSize(new Dimension(200, 20));
comp = label;
}
if (comp instanceof JComponent) {
((JComponent) comp).putClientProperty("Id", ComponentFactory.getWebID(form, meta));
}
return comp;
}
use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.
the class JSNGWebComponent method setHandler.
@Override
public void setHandler(String handlerName, JSMethod value) {
WebComponent webComponent = getBaseComponent(false);
WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(webComponent.getTypeName());
if (spec != null) {
String name = handlerName;
if (spec.getHandler(name) == null) {
name = name + "MethodID";
}
if (spec.getHandler(name) != null) {
setJSONProperty(name, value);
getBaseComponent(true).putMethodParameters(name, new ArrayList(), value instanceof JSMethodWithArguments ? Arrays.asList(((JSMethodWithArguments) value).getArguments()) : null);
} else {
int i = name.indexOf('.');
if (i > 0) {
String firstPart = name.substring(0, i);
PropertyDescription property = spec.getProperty(firstPart);
if (property != null && property.getType() instanceof IFormComponentType) {
// undefined means remove the property
Object convertedValue = fromRhinoToDesignValue(value, property, application, this, handlerName);
webComponent.setProperty(firstPart, convertedValue);
// TODO store the method parameters/arguments..
return;
}
}
Debug.log("Error: component " + webComponent.getTypeName() + " does not declare a handler named " + handlerName + ".");
}
}
}
use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.
the class JSNGWebComponent method resetJSONProperty.
@Override
public void resetJSONProperty(String propertyName) {
try {
WebComponent webComponent = getBaseComponent(true);
WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(webComponent.getTypeName());
Pair<PropertyDescription, String> propAndName = getPropertyDescriptionAndName(propertyName, spec);
PropertyDescription pd = propAndName.getLeft();
if (pd != null && pd.getType() instanceof IFormComponentType) {
IFormComponentRhinoConverter converter = ((IFormComponentType) pd.getType()).getFormComponentRhinoConverter(pd.getName(), webComponent.getProperty(pd.getName()), application, this);
// undefined means remove the property
Object convertedValue = fromRhinoToDesignValue(Context.getUndefinedValue(), propAndName.getLeft(), application, this, propertyName);
webComponent.setProperty(propAndName.getRight(), convertedValue);
} else if (pd != null)
webComponent.clearProperty(propertyName);
} catch (JSONException e) {
Debug.error(e);
}
}
use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.
the class JSNGWebComponent method setJSONProperty.
@Override
public void setJSONProperty(String propertyName, Object value) {
try {
WebComponent webComponent = getBaseComponent(true);
WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(webComponent.getTypeName());
Pair<PropertyDescription, String> propAndName = getPropertyDescriptionAndName(propertyName, spec);
if (propAndName.getLeft() == null) {
Debug.warn("Property '" + propertyName + "' not found in spec file of: " + webComponent.getTypeName() + ". It was set using JSWebComponent.setJSONProperty API.");
}
Object convertedValue = fromRhinoToDesignValue(value, propAndName.getLeft(), application, this, propertyName);
webComponent.setProperty(propAndName.getRight(), convertedValue);
} catch (JSONException e) {
Debug.error(e);
}
}
Aggregations