Search in sources :

Example 1 with BaseWebObject

use of org.sablo.BaseWebObject in project servoy-client by Servoy.

the class DataAdapterList method setFindMode.

@Override
public void setFindMode(boolean findMode) {
    if (this.findMode != findMode) {
        this.findMode = findMode;
        ((BaseWebObject) formController.getFormUI()).setProperty("findmode", findMode);
        for (IFindModeAwarePropertyValue x : findModeAwareProperties) {
            x.findModeChanged(findMode);
        }
    }
}
Also used : IFindModeAwarePropertyValue(com.servoy.j2db.server.ngclient.property.IFindModeAwarePropertyValue) BaseWebObject(org.sablo.BaseWebObject)

Example 2 with BaseWebObject

use of org.sablo.BaseWebObject in project servoy-client by Servoy.

the class WebServiceScriptable method put.

@Override
public void put(String name, Scriptable start, Object value) {
    PropertyDescription desc = serviceSpecification.getProperty(name);
    BaseWebObject service = (BaseWebObject) application.getWebsocketSession().getClientService(serviceSpecification.getName());
    if (desc != null) {
        Object previousVal = service.getProperty(name);
        Object val = NGConversions.INSTANCE.convertRhinoToSabloComponentValue(value, previousVal, desc, service);
        if (val != previousVal)
            service.setProperty(name, val);
    } else {
        WebObjectFunctionDefinition apiFunction = serviceSpecification.getApiFunction(name);
        // don't allow api to be overwritten.
        if (apiFunction != null)
            return;
        // TODO conversion should happen from string (color representation) to Color object.
        // DesignConversion.toObject(value, type)
        service.setProperty(name, value);
    }
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) BaseWebObject(org.sablo.BaseWebObject) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) WebObjectFunctionDefinition(org.sablo.specification.WebObjectFunctionDefinition) BaseWebObject(org.sablo.BaseWebObject)

Example 3 with BaseWebObject

use of org.sablo.BaseWebObject in project servoy-client by Servoy.

the class RecordPropertyType method fromJSON.

@Override
public IRecordInternal fromJSON(Object newJSONValue, IRecordInternal previousSabloValue, PropertyDescription pd, IBrowserConverterContext dataConverterContext, ValueReference<Boolean> returnValueAdjustedIncommingValue) {
    IRecordInternal record = null;
    if (newJSONValue instanceof JSONObject) {
        JSONObject jsonRecord = (JSONObject) newJSONValue;
        BaseWebObject webObject = dataConverterContext.getWebObject();
        if (webObject != null && jsonRecord.has(FoundsetTypeSabloValue.ROW_ID_COL_KEY)) {
            String rowIDValue = jsonRecord.optString(FoundsetTypeSabloValue.ROW_ID_COL_KEY);
            Pair<String, Integer> splitHashAndIndex = FoundsetTypeSabloValue.splitPKHashAndIndex(rowIDValue);
            if (jsonRecord.has(FoundsetTypeSabloValue.FOUNDSET_ID)) {
                int foundsetID = Utils.getAsInteger(jsonRecord.get(FoundsetTypeSabloValue.FOUNDSET_ID));
                if (foundsetID >= 0 && webObject instanceof IContextProvider) {
                    IFoundSetInternal foundset = ((IContextProvider) webObject).getDataConverterContext().getApplication().getFoundSetManager().findFoundset(foundsetID);
                    if (foundset != null) {
                        int recordIndex = foundset.getRecordIndex(splitHashAndIndex.getLeft(), splitHashAndIndex.getRight().intValue());
                        if (recordIndex != -1) {
                            return foundset.getRecord(recordIndex);
                        }
                    }
                }
            }
            Collection<PropertyDescription> properties = webObject.getSpecification().getProperties(FoundsetPropertyType.INSTANCE);
            for (PropertyDescription foundsetPd : properties) {
                FoundsetTypeSabloValue fsSablo = (FoundsetTypeSabloValue) webObject.getProperty(foundsetPd.getName());
                int recordIndex = fsSablo.getFoundset().getRecordIndex(splitHashAndIndex.getLeft(), splitHashAndIndex.getRight().intValue());
                if (recordIndex != -1) {
                    record = fsSablo.getFoundset().getRecord(recordIndex);
                    break;
                }
            }
        }
        if (// $NON-NLS-1$
        record == null && jsonRecord.has("recordhash")) {
            // $NON-NLS-1$
            record = getReference(jsonRecord.optString("recordhash"));
        }
    }
    return record;
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) JSONObject(org.json.JSONObject) IContextProvider(com.servoy.j2db.server.ngclient.IContextProvider) FoundsetTypeSabloValue(com.servoy.j2db.server.ngclient.property.FoundsetTypeSabloValue) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) BaseWebObject(org.sablo.BaseWebObject)

Example 4 with BaseWebObject

use of org.sablo.BaseWebObject in project servoy-client by Servoy.

the class JSDNDEventType method fromJSON.

@Override
public JSDNDEvent fromJSON(Object newJSONValue, JSDNDEvent previousSabloValue, PropertyDescription pd, IBrowserConverterContext dataConverterContext, ValueReference<Boolean> returnValueAdjustedIncommingValue) {
    JSDNDEvent event = null;
    if (newJSONValue instanceof JSONObject) {
        JSONObject jsonObject = (JSONObject) newJSONValue;
        // $NON-NLS-1$
        event = getReference(jsonObject.optString("jseventhash"));
        if (event == null) {
            BaseWebObject webObject = dataConverterContext.getWebObject();
            event = new JSDNDEvent();
            JSEventType.fillJSEvent(event, jsonObject, webObject, null);
        }
    }
    return event;
}
Also used : JSDNDEvent(com.servoy.j2db.dnd.JSDNDEvent) JSONObject(org.json.JSONObject) BaseWebObject(org.sablo.BaseWebObject)

Example 5 with BaseWebObject

use of org.sablo.BaseWebObject in project servoy-client by Servoy.

the class FormatPropertyType method writeComponentFormatToJSON.

public JSONWriter writeComponentFormatToJSON(JSONWriter writer, String key, ComponentFormat format, DataConversion dataConversions, IBrowserConverterContext dataConverterContext) {
    Map<String, Object> map = new HashMap<>();
    String type = Column.getDisplayTypeString(format.uiType);
    map.put("type", type);
    boolean isMask = format.parsedFormat.isMask();
    boolean isAllUppercase = format.parsedFormat.isAllUpperCase();
    boolean isAllLowercase = format.parsedFormat.isAllLowerCase();
    String placeHolder = null;
    if (format.parsedFormat.getPlaceHolderString() != null)
        placeHolder = format.parsedFormat.getPlaceHolderString();
    else if (format.parsedFormat.getPlaceHolderCharacter() != 0)
        placeHolder = Character.toString(format.parsedFormat.getPlaceHolderCharacter());
    String mask = format.parsedFormat.getEditFormat();
    if (isMask && type.equals("DATETIME")) {
        mask = format.parsedFormat.getDateMask();
        if (placeHolder == null)
            placeHolder = format.parsedFormat.getDisplayFormat();
    } else if (format.parsedFormat.getDisplayFormat() != null && type.equals("TEXT")) {
        isMask = true;
        mask = format.parsedFormat.getDisplayFormat();
    }
    map.put("isMask", Boolean.valueOf(isMask));
    map.put("isRaw", Boolean.valueOf(format.parsedFormat.isRaw()));
    map.put("edit", mask);
    map.put("placeHolder", placeHolder);
    map.put("allowedCharacters", format.parsedFormat.getAllowedCharacters());
    map.put("display", format.parsedFormat.getDisplayFormat());
    map.put("isNumberValidator", Boolean.valueOf(format.parsedFormat.isNumberValidator()));
    if (type.equals("NUMBER") || type.equals("INTEGER") || format.parsedFormat.isNumberValidator()) {
        BaseWebObject webObject = dataConverterContext.getWebObject();
        Locale clientLocale;
        if (webObject instanceof IContextProvider) {
            clientLocale = ((IContextProvider) webObject).getDataConverterContext().getApplication().getLocale();
        } else {
            Debug.warn("Cannot get client locale for : " + webObject.toString() + " , using system default");
            clientLocale = Locale.getDefault();
        }
        DecimalFormatSymbols dfs = RoundHalfUpDecimalFormat.getDecimalFormatSymbols(clientLocale);
        // the commented out values are already available client-side in numeral.localeData(); they are taken from there now
        // map.put("decimalSeparator", String.valueOf(dfs.getDecimalSeparator()));
        // map.put("groupingSeparator", String.valueOf(dfs.getGroupingSeparator()));
        // map.put("currencySymbol", dfs.getCurrencySymbol());
        map.put("percent", String.valueOf(dfs.getPercent()));
    }
    if (format.parsedFormat.getMaxLength() != null) {
        map.put("maxLength", format.parsedFormat.getMaxLength());
    }
    if (isAllUppercase)
        map.put("uppercase", Boolean.valueOf(isAllUppercase));
    else if (isAllLowercase)
        map.put("lowercase", Boolean.valueOf(isAllLowercase));
    // here dataConversions is not used I think, could be null
    return JSONUtils.toBrowserJSONFullValue(writer, key, map, null, dataConversions, null);
}
Also used : Locale(java.util.Locale) IContextProvider(com.servoy.j2db.server.ngclient.IContextProvider) DecimalFormatSymbols(java.text.DecimalFormatSymbols) HashMap(java.util.HashMap) JSONObject(org.json.JSONObject) BaseWebObject(org.sablo.BaseWebObject) BaseWebObject(org.sablo.BaseWebObject)

Aggregations

BaseWebObject (org.sablo.BaseWebObject)9 JSONObject (org.json.JSONObject)6 IContextProvider (com.servoy.j2db.server.ngclient.IContextProvider)2 PropertyDescription (org.sablo.specification.PropertyDescription)2 WebObjectFunctionDefinition (org.sablo.specification.WebObjectFunctionDefinition)2 ApplicationException (com.servoy.j2db.ApplicationException)1 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)1 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)1 JSDNDEvent (com.servoy.j2db.dnd.JSDNDEvent)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 ElementScope (com.servoy.j2db.scripting.ElementScope)1 FormScope (com.servoy.j2db.scripting.FormScope)1 JSEvent (com.servoy.j2db.scripting.JSEvent)1 PluginScope (com.servoy.j2db.scripting.PluginScope)1 FormElement (com.servoy.j2db.server.ngclient.FormElement)1 INGApplication (com.servoy.j2db.server.ngclient.INGApplication)1 IWebFormController (com.servoy.j2db.server.ngclient.IWebFormController)1 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)1 WebFormUI (com.servoy.j2db.server.ngclient.WebFormUI)1 RuntimeLegacyComponent (com.servoy.j2db.server.ngclient.component.RuntimeLegacyComponent)1