Search in sources :

Example 1 with ComponentTypeSabloValue

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);
    }
}
Also used : JSONObject(org.json.JSONObject) ComponentTypeSabloValue(com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue)

Example 2 with ComponentTypeSabloValue

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;
}
Also used : FormComponentCache(com.servoy.j2db.server.ngclient.FormElementHelper.FormComponentCache) Form(com.servoy.j2db.persistence.Form) PropertyDescriptionBuilder(org.sablo.specification.PropertyDescriptionBuilder) ArrayList(java.util.ArrayList) FormElement(com.servoy.j2db.server.ngclient.FormElement) INGFormElement(com.servoy.j2db.server.ngclient.INGFormElement) ComponentTypeSabloValue(com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue) ComponentTypeFormElementValue(com.servoy.j2db.server.ngclient.property.ComponentTypeFormElementValue) PropertyDescription(org.sablo.specification.PropertyDescription) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject)

Example 3 with ComponentTypeSabloValue

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);
    }
}
Also used : ComponentTypeSabloValue(com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue)

Example 4 with ComponentTypeSabloValue

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;
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) ScriptableObject(org.mozilla.javascript.ScriptableObject) ArrayList(java.util.ArrayList) List(java.util.List) ComponentTypeSabloValue(com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue)

Example 5 with ComponentTypeSabloValue

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();
}
Also used : DataConversion(org.sablo.websocket.utils.DataConversion) ComponentTypeSabloValue(com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue)

Aggregations

ComponentTypeSabloValue (com.servoy.j2db.server.ngclient.property.ComponentTypeSabloValue)6 ArrayList (java.util.ArrayList)2 JSONObject (org.json.JSONObject)2 PropertyDescription (org.sablo.specification.PropertyDescription)2 DataConversion (org.sablo.websocket.utils.DataConversion)2 Form (com.servoy.j2db.persistence.Form)1 FormElement (com.servoy.j2db.server.ngclient.FormElement)1 FormComponentCache (com.servoy.j2db.server.ngclient.FormElementHelper.FormComponentCache)1 INGFormElement (com.servoy.j2db.server.ngclient.INGFormElement)1 ComponentTypeFormElementValue (com.servoy.j2db.server.ngclient.property.ComponentTypeFormElementValue)1 List (java.util.List)1 ScriptableObject (org.mozilla.javascript.ScriptableObject)1 PropertyDescriptionBuilder (org.sablo.specification.PropertyDescriptionBuilder)1