use of com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue in project servoy-client by Servoy.
the class FormComponentSabloValue method browserUpdatesReceived.
public void browserUpdatesReceived(JSONArray array) {
ComponentTypeSabloValue[] components = getComponents();
for (int i = 0; i < array.length(); i++) {
Object comp = array.get(i);
components[i].browserUpdatesReceived(comp);
}
}
use of com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue in project servoy-client by Servoy.
the class FormComponentSabloValue method getComponents.
private ComponentTypeSabloValue[] getComponents() {
FormComponentCache formComponentCache = getCache();
if (currentFormComponentCache != formComponentCache) {
List<FormElement> elements = formComponentCache.getFormComponentElements();
List<ComponentTypeSabloValue> componentsList = new ArrayList<ComponentTypeSabloValue>(elements.size());
PropertyPath path = new PropertyPath();
path.add(component.getName());
path.add("containedForm");
path.add("childElements");
JSONObject tags = new JSONObject();
tags.put(ComponentTypeSabloValue.TAG_ADD_TO_ELEMENTS_SCOPE, true);
PropertyDescription compPd = new PropertyDescriptionBuilder().withName(pd.getName()).withType(ComponentPropertyType.INSTANCE).withConfig(pd.getConfig()).withTags(tags).build();
int j = 0;
for (FormElement element : elements) {
path.add(j);
ComponentTypeFormElementValue elementValue = ComponentPropertyType.INSTANCE.getFormElementValue(null, compPd, path, element, dal.getApplication().getFlattenedSolution());
ComponentTypeSabloValue ctsv = ComponentPropertyType.INSTANCE.toSabloComponentValue(elementValue, compPd, element, component, dal);
if (ctsv != null) {
// if it is null then it is probably a child component that was blocked by security (visibility == false); in that case just ignore it (similar to what portal does through .spec setting on comp. array to ignore null values at runtime)
j++;
componentsList.add(ctsv);
}
path.backOneLevel();
if (element.getWebComponentSpec() != null) {
Collection<PropertyDescription> properties = element.getWebComponentSpec().getProperties(FormComponentPropertyType.INSTANCE);
if (properties.size() > 0) {
for (PropertyDescription pd : properties) {
Object propertyValue = element.getPropertyValue(pd.getName());
Form frm = FormComponentPropertyType.INSTANCE.getForm(propertyValue, dal.getApplication().getFlattenedSolution());
if (frm == null)
continue;
FormComponentCache innerCache = FormElementHelper.INSTANCE.getFormComponentCache(element, pd, (JSONObject) propertyValue, frm, dal.getApplication().getFlattenedSolution());
List<FormElement> innerElements = innerCache.getFormComponentElements();
for (FormElement innerElement : innerElements) {
path.add(j);
elementValue = ComponentPropertyType.INSTANCE.getFormElementValue(null, compPd, path, innerElement, dal.getApplication().getFlattenedSolution());
// use main property
ctsv = ComponentPropertyType.INSTANCE.toSabloComponentValue(elementValue, compPd, innerElement, component, dal);
if (ctsv != null) {
// if it is null then it is probably a child component that was blocked by security (visibility == false); in that case just ignore it (similar to what portal does through .spec setting on comp. array to ignore null values at runtime)
j++;
componentsList.add(ctsv);
}
path.backOneLevel();
}
}
}
}
}
// re-attach
if (currentFormComponentCache != null && changeMonitor != null && webObjectContext != null) {
for (ComponentTypeSabloValue componentTypeSabloValue : componentsList) {
componentTypeSabloValue.attachToBaseObject(changeMonitor, webObjectContext);
}
}
currentFormComponentCache = formComponentCache;
components = componentsList.toArray(new ComponentTypeSabloValue[0]);
}
return components;
}
use of com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue in project servoy-client by Servoy.
the class FormComponentSabloValue method attachToBaseObject.
@Override
public void attachToBaseObject(IChangeListener changeMonitor, IWebObjectContext webObjectContext) {
this.changeMonitor = changeMonitor;
this.webObjectContext = webObjectContext;
ComponentTypeSabloValue[] components = getComponents();
for (ComponentTypeSabloValue componentTypeSabloValue : components) {
componentTypeSabloValue.attachToBaseObject(changeMonitor, webObjectContext);
}
}
use of com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue in project servoy-client by Servoy.
the class RhinoMapOrArrayWrapper method get.
@Override
public Object get(String name, Scriptable start) {
Object value = getAsSabloValue(name);
if (wrappedValue instanceof List) {
if (name.equals("length"))
return value;
List list = (List) wrappedValue;
if (list.size() > 0) {
for (Object element : list) {
if (element instanceof ComponentTypeSabloValue && Utils.equalObjects(name, ((ComponentTypeSabloValue) element).getName())) {
return NGConversions.INSTANCE.convertSabloComponentToRhinoValue(element, ((ComponentTypeSabloValue) element).getComponentPropertyDescription(), webObjectContext, start);
}
}
}
// then it will be searched for in prototype that is a native array prototype
return Scriptable.NOT_FOUND;
}
PropertyDescription propDesc = propertyDescription.getProperty(name);
return propDesc != null ? NGConversions.INSTANCE.convertSabloComponentToRhinoValue(value, propDesc, webObjectContext, start) : Scriptable.NOT_FOUND;
}
use of com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue in project servoy-client by Servoy.
the class FormComponentSabloValue method fullToJSON.
@SuppressWarnings("nls")
public void fullToJSON(JSONWriter writer, DataConversion clientConversion, FormComponentPropertyType formComponentPropertyType, IBrowserConverterContext dataConverterContext) {
clientConversion.convert(FormComponentPropertyType.TYPE_NAME);
writer.object();
writer.key("uuid");
writer.value(getCache().getHtmlTemplateUUIDForAngular());
writer.key("formHeight");
writer.value(form.getSize().height);
writer.key("formWidth");
writer.value(form.getSize().width);
writer.key("absoluteLayout");
writer.value(!form.isResponsiveLayout());
writer.key(IContentSpecConstants.PROPERTY_USE_CSS_POSITION);
writer.value(form.getUseCssPosition());
writer.key("startName");
writer.value(elementStartName);
writer.key("childElements");
writer.array();
DataConversion componentConversionMarkers = new DataConversion();
componentConversionMarkers.pushNode("childElements");
ComponentTypeSabloValue[] comps = getComponents();
for (int i = 0; i < comps.length; i++) {
componentConversionMarkers.pushNode(String.valueOf(i));
comps[i].fullToJSON(writer, componentConversionMarkers, ComponentPropertyType.INSTANCE);
componentConversionMarkers.popNode();
}
componentConversionMarkers.popNode();
writer.endArray();
if (componentConversionMarkers.getConversions().size() > 0) {
writer.key(JSONUtils.TYPES_KEY).object();
JSONUtils.writeConversions(writer, componentConversionMarkers.getConversions());
writer.endObject();
}
writer.endObject();
}
Aggregations