Search in sources :

Example 1 with ReadonlySabloValue

use of com.servoy.j2db.server.ngclient.property.types.ReadonlySabloValue in project servoy-client by Servoy.

the class RuntimeWebGroup method putProperty.

private void putProperty(String propertyName, Object value, WebFormComponent component) {
    if (propertyName == null)
        return;
    Object previousVal = component.getProperty(propertyName);
    Object val = null;
    if (propertyName.equals(WebFormUI.READONLY)) {
        val = Boolean.valueOf((boolean) value);
        Object readonlyproperty = component.getProperty(WebFormUI.READONLY);
        if (readonlyproperty instanceof ReadonlySabloValue) {
            ReadonlySabloValue oldValue = (ReadonlySabloValue) readonlyproperty;
            // use the rhino conversion to convert from boolean to ReadOnlySabloValue
            PropertyDescription pd = component.getFormElement().getWebComponentSpec().getProperty(WebFormUI.READONLY);
            if (pd != null)
                val = ReadonlyPropertyType.INSTANCE.toSabloComponentValue(val, oldValue, pd, component);
        }
    } else {
        val = NGConversions.INSTANCE.convertRhinoToSabloComponentValue(value, previousVal, component.getSpecification().getProperties().get(propertyName), component);
    }
    if (val != previousVal)
        component.setProperty(propertyName, val);
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) ReadonlySabloValue(com.servoy.j2db.server.ngclient.property.types.ReadonlySabloValue)

Example 2 with ReadonlySabloValue

use of com.servoy.j2db.server.ngclient.property.types.ReadonlySabloValue in project servoy-client by Servoy.

the class WebFormUI method propagatePropertyToAllComponents.

private void propagatePropertyToAllComponents(String property, boolean value) {
    for (WebComponent component : getComponents()) {
        Object newValue = Boolean.valueOf(value);
        if (READONLY.equals(property)) {
            Object readonlyproperty = component.getProperty(READONLY);
            if (readonlyproperty instanceof ReadonlySabloValue) {
                ReadonlySabloValue oldValue = (ReadonlySabloValue) readonlyproperty;
                // use the rhino conversion to convert from boolean to ReadOnlySabloValue
                PropertyDescription pd = ((WebFormComponent) component).getFormElement().getWebComponentSpec().getProperty(READONLY);
                if (pd != null)
                    newValue = ReadonlyPropertyType.INSTANCE.toSabloComponentValue(Boolean.valueOf(value), oldValue, pd, component);
            }
        }
        component.setProperty(property, newValue);
    }
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) WebComponent(org.sablo.WebComponent) RuntimeWebComponent(com.servoy.j2db.server.ngclient.component.RuntimeWebComponent) JSONObject(org.json.JSONObject) ReadonlySabloValue(com.servoy.j2db.server.ngclient.property.types.ReadonlySabloValue)

Example 3 with ReadonlySabloValue

use of com.servoy.j2db.server.ngclient.property.types.ReadonlySabloValue in project servoy-client by Servoy.

the class WebFormController method focusField.

@SuppressWarnings("nls")
@Override
protected boolean focusField(String fieldName, boolean skipReadonly) {
    WebComponent component = null;
    WebObjectFunctionDefinition apiFunction = null;
    if (fieldName != null) {
        component = formUI.getComponent(fieldName);
        if (component == null) {
            RuntimeWebComponent[] runtimeComponents = getWebComponentElements();
            if (runtimeComponents != null) {
                for (RuntimeWebComponent runtimeComponent : runtimeComponents) {
                    if (Utils.equalObjects(fieldName, runtimeComponent.getComponent().getName())) {
                        component = runtimeComponent.getComponent();
                        break;
                    }
                }
            }
        }
        if (component != null) {
            apiFunction = component.getSpecification().getApiFunction("requestFocus");
        }
    } else {
        Collection<WebComponent> tabSequenceComponents = getTabSequenceComponents();
        if (tabSequenceComponents != null) {
            for (WebComponent seqComponent : tabSequenceComponents) {
                apiFunction = seqComponent.getSpecification().getApiFunction("requestFocus");
                if (apiFunction != null && seqComponent.isVisible()) {
                    if (skipReadonly) {
                        Object value = seqComponent.getProperty(WebFormUI.READONLY);
                        if (value instanceof ReadonlySabloValue) {
                            value = Boolean.valueOf(((ReadonlySabloValue) value).getValue());
                        }
                        if (Boolean.TRUE.equals(value)) {
                            continue;
                        }
                    }
                    component = seqComponent;
                    break;
                }
            }
        }
    }
    if (apiFunction != null && component != null) {
        component.invokeApi(apiFunction, null);
        return true;
    }
    return false;
}
Also used : WebComponent(org.sablo.WebComponent) ReadonlySabloValue(com.servoy.j2db.server.ngclient.property.types.ReadonlySabloValue) WebObjectFunctionDefinition(org.sablo.specification.WebObjectFunctionDefinition)

Aggregations

ReadonlySabloValue (com.servoy.j2db.server.ngclient.property.types.ReadonlySabloValue)3 WebComponent (org.sablo.WebComponent)2 PropertyDescription (org.sablo.specification.PropertyDescription)2 RuntimeWebComponent (com.servoy.j2db.server.ngclient.component.RuntimeWebComponent)1 JSONObject (org.json.JSONObject)1 WebObjectFunctionDefinition (org.sablo.specification.WebObjectFunctionDefinition)1