Search in sources :

Example 6 with INGApplication

use of com.servoy.j2db.server.ngclient.INGApplication in project servoy-client by Servoy.

the class DataproviderTypeSabloValue method dataProviderOrRecordChanged.

@Override
public void dataProviderOrRecordChanged(final IRecordInternal record, final String dataProvider, final boolean isFormDP, final boolean isGlobalDP, boolean fireChangeEvent) {
    // TODO can type or fieldFormat change, for example in scripting the format is reset (but type shouldn't really change)
    IDataProviderLookup dpLookup = new FormAndTableDataProviderLookup(servoyDataConverterContext.getApplication().getFlattenedSolution(), servoyDataConverterContext.getForm().getForm(), record != null ? record.getParentFoundSet().getTable() : null);
    Collection<PropertyDescription> properties = webObjectContext.getProperties(TypesRegistry.getType(FormatPropertyType.TYPE_NAME));
    FormatTypeSabloValue formatSabloValue = null;
    for (PropertyDescription formatPd : properties) {
        // see whether format if "for" this property (dataprovider)
        Object formatConfig = formatPd.getConfig();
        if (formatConfig instanceof String[] && Arrays.asList((String[]) formatConfig).indexOf(dpPD.getName()) != -1) {
            INGApplication application = servoyDataConverterContext.getApplication();
            formatSabloValue = (FormatTypeSabloValue) webObjectContext.getProperty(formatPd.getName());
            if (formatSabloValue != null) {
                if (formatSabloValue.getFormatDesignValue() != null) {
                    fieldFormat = ComponentFormat.getComponentFormat(formatSabloValue.getFormatDesignValue(), dataProviderID, dpLookup, application);
                }
                break;
            }
        }
    }
    if (fieldFormat != null) {
        typeOfDP = NGUtils.getDataProviderPropertyDescription(fieldFormat.uiType, getDataProviderConfig().hasParseHtml(), fieldFormat.parsedFormat.useLocalDateTime());
        if (record instanceof FindState) {
            ((FindState) record).setFormat(dataProviderID, fieldFormat.parsedFormat);
        }
    } else {
        // see type of dataprovider; this is done only once - first time we get a new record
        typeOfDP = NGUtils.getDataProviderPropertyDescription(dataProviderID, servoyDataConverterContext.getApplication(), servoyDataConverterContext.getForm().getForm(), record != null ? record.getParentFoundSet().getTable() : null, getDataProviderConfig().hasParseHtml(), formatSabloValue != null ? formatSabloValue.getComponentFormat().parsedFormat.useLocalDateTime() : false);
    }
    if (dpPD.hasTag(TAG_TYPE_NAME)) {
        IPropertyType<?> specType = TypesRegistry.getType((String) dpPD.getTag(TAG_TYPE_NAME));
        if (specType != null && (typeOfDP == null || !specType.getClass().isAssignableFrom(typeOfDP.getClass()))) {
            typeOfDP = new PropertyDescriptionBuilder().withName("Spec type hint").withType(specType).build();
        }
    }
    String dpID = dataProviderID;
    IDataProvider dp = null;
    if (dpLookup != null) {
        try {
            dp = dpLookup.getDataProvider(dataProviderID);
            if (dp != null) {
                dpID = dp.getDataProviderID();
            }
        } catch (RepositoryException e) {
            Debug.error(e);
        }
    }
    if (globalRelationName != null) {
        try {
            IFoundSetInternal newRelatedFoundset = servoyDataConverterContext.getApplication().getFoundSetManager().getGlobalRelatedFoundSet(globalRelationName);
            if (newRelatedFoundset != globalRelatedFoundset) {
                if (globalRelatedFoundsetListener == null) {
                    globalRelatedFoundsetListener = new IFoundSetEventListener() {

                        @Override
                        public void foundSetChanged(FoundSetEvent e) {
                            if (e.getType() == FoundSetEvent.CONTENTS_CHANGED) {
                                dataProviderOrRecordChanged(DataproviderTypeSabloValue.this.dataAdapterList.getRecord(), null, false, false, true);
                            }
                        }
                    };
                } else if (globalRelatedFoundset != null) {
                    globalRelatedFoundset.removeFoundSetEventListener(globalRelatedFoundsetListener);
                }
                globalRelatedFoundset = newRelatedFoundset;
                globalRelatedFoundset.addFoundSetEventListener(globalRelatedFoundsetListener);
            }
        } catch (Exception ex) {
            Debug.error(ex);
        }
    }
    if (relatedFoundsetSelectionListener != null) {
        try {
            ArrayList<IFoundSetInternal> newRelatedFoundsets = getRelatedFoundsets(record, relationName);
            boolean equals = testByReference(newRelatedFoundsets, this.relatedFoundsets);
            if (!equals) {
                IDataProvider column = dp;
                if (column instanceof ColumnWrapper) {
                    column = ((ColumnWrapper) column).getColumn();
                }
                boolean isAggregate = (column instanceof IColumn) ? ((IColumn) column).isAggregate() : false;
                if (isAggregate && relatedFoundsets.size() > 0) {
                    relatedFoundsets.get(relatedFoundsets.size() - 1).removeAggregateModificationListener(relatedRecordModificationListener);
                }
                for (IFoundSetInternal relatedFoundset : relatedFoundsets) {
                    ((ISwingFoundSet) relatedFoundset).getSelectionModel().removeListSelectionListener(relatedFoundsetSelectionListener);
                }
                relatedFoundsets = newRelatedFoundsets;
                for (IFoundSetInternal relatedFoundset : relatedFoundsets) {
                    ((ISwingFoundSet) relatedFoundset).getSelectionModel().addListSelectionListener(relatedFoundsetSelectionListener);
                }
                if (isAggregate && relatedFoundsets.size() > 0) {
                    relatedFoundsets.get(relatedFoundsets.size() - 1).addAggregateModificationListener(relatedRecordModificationListener);
                }
            }
        } catch (Exception ex) {
            Debug.error(ex);
        }
    }
    if (relatedRecordModificationListener != null) {
        try {
            ArrayList<IRecordInternal> newRelatedRecords = getRelatedRecords(record, relationName);
            boolean equals = testByReference(newRelatedRecords, this.relatedRecords);
            if (!equals) {
                for (IRecordInternal relatedRecord : relatedRecords) {
                    relatedRecord.removeModificationListener(relatedRecordModificationListener);
                }
                relatedRecords = newRelatedRecords;
                for (IRecordInternal relatedRecord : relatedRecords) {
                    relatedRecord.addModificationListener(relatedRecordModificationListener);
                }
            }
        } catch (Exception ex) {
            Debug.error(ex);
        }
    }
    Object v = com.servoy.j2db.dataprocessing.DataAdapterList.getValueObject(record, servoyDataConverterContext.getForm().getFormScope(), dpID);
    if (v == Scriptable.NOT_FOUND)
        v = null;
    if (fieldFormat != null && !findMode) {
        // if it has an UI converter, transform it from the record/scope value into the UI value
        v = ComponentFormat.applyUIConverterToObject(v, dataProviderID, servoyDataConverterContext.getApplication().getFoundSetManager(), fieldFormat);
    }
    v = replaceTagsIfNeeded(v);
    boolean changed = ((v != uiValue) && (v == null || !v.equals(uiValue)));
    uiValue = v;
    if (changed) {
        jsonValue = null;
    }
    if (// if it is a foundset related DAL then always call valuechanged (the value can be of a previous row)
    fireChangeEvent && (changed || dataAdapterList instanceof FoundsetDataAdapterList)) {
        changeMonitor.valueChanged();
    }
}
Also used : IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) PropertyDescriptionBuilder(org.sablo.specification.PropertyDescriptionBuilder) IDataProvider(com.servoy.j2db.persistence.IDataProvider) INGApplication(com.servoy.j2db.server.ngclient.INGApplication) FindState(com.servoy.j2db.dataprocessing.FindState) FormAndTableDataProviderLookup(com.servoy.j2db.FormAndTableDataProviderLookup) FoundsetDataAdapterList(com.servoy.j2db.server.ngclient.property.FoundsetDataAdapterList) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) ColumnWrapper(com.servoy.j2db.persistence.ColumnWrapper) RepositoryException(com.servoy.j2db.persistence.RepositoryException) FoundSetEvent(com.servoy.j2db.dataprocessing.FoundSetEvent) JSONException(org.json.JSONException) ParseException(java.text.ParseException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) PropertyDescription(org.sablo.specification.PropertyDescription) IColumn(com.servoy.j2db.persistence.IColumn) IDataProviderLookup(com.servoy.j2db.persistence.IDataProviderLookup) IFoundSetEventListener(com.servoy.j2db.dataprocessing.IFoundSetEventListener)

Example 7 with INGApplication

use of com.servoy.j2db.server.ngclient.INGApplication in project servoy-client by Servoy.

the class DynamicClientFunctionPropertyType method toJSON.

@Override
public JSONWriter toJSON(JSONWriter writer, String key, BrowserFunction sabloValue, PropertyDescription propertyDescription, DataConversion clientConversion, IBrowserConverterContext dataConverterContext) throws JSONException {
    if (sabloValue != null) {
        INGApplication application = sabloValue.getApplication();
        if (// $NON-NLS-1$
        application.getRuntimeProperties().containsKey("NG2")) {
            // $NON-NLS-1$
            clientConversion.convert("clientfunction");
            JSONUtils.addKeyIfPresent(writer, key);
            String uuid = application.registerClientFunction(sabloValue.getFunctionString());
            writer.value(uuid);
            return writer;
        }
    }
    return null;
}
Also used : INGApplication(com.servoy.j2db.server.ngclient.INGApplication)

Example 8 with INGApplication

use of com.servoy.j2db.server.ngclient.INGApplication in project servoy-client by Servoy.

the class FormatTypeSabloValue method getSabloValue.

protected ComponentFormat getSabloValue(String formatValue, String dataproviderId, Object valuelistId, String foundsetId, IWebObjectContext webObjectCntxt) {
    INGApplication application = ((WebFormComponent) webObjectCntxt.getUnderlyingWebObject()).getDataConverterContext().getApplication();
    IDataProviderLookup dataProviderLookup = null;
    // IMPORTANT: here we use the for: configs in .spec file
    // 
    // if you have for: [valuelist, dataprovider] then 2 things can happen:
    // - valuelist if it has both real and display values - forces the type; it is either TEXT (custom vl., global method vl.) or the 'display' column type in case it's a DB valuelist
    // - valuelist if not real/display but only one kind of values: here it is required in docs in the spec file that the valuelist property also defines "for": dataprovider if format
    // defines both "for" valuelist and dataprovider => valuelist doesn't force the type and then the dataprovider will decide the type
    // 
    // if you have just for: dataprovider the the dataprovider property determines the type
    // if you have just for: valuelist (TODO) - this is currently not properly supported - as here we should get the type always from the VL (for both display and real values) - as we don't have a dataprovider to fall back on
    isValuelistFormatSet = false;
    if (valuelistId != null) {
        // if we have a "for" valuelist, see if this valuelist forces the format type due to display values (when they are separate from real values)
        // otherwise it will do nothing and loop/fallback to the other if clause below which checks the "for" dataprovider
        ValueList valuelistPersist = ValueListTypeSabloValue.getValuelistPersist(valuelistId, application);
        if (valuelistPersist != null) {
            IDataProvider dataProvider = null;
            ITable table;
            try {
                if (valuelistPersist.getRelationName() != null) {
                    Relation[] relations = application.getFlattenedSolution().getRelationSequence(valuelistPersist.getRelationName());
                    table = application.getFlattenedSolution().getTable(relations[relations.length - 1].getForeignDataSource());
                } else {
                    table = application.getFlattenedSolution().getTable(valuelistPersist.getDataSource());
                }
                if (table != null) {
                    // if the format is for a table valuelist - the type to be used is the one of the dp chosen as 'display' in the valuelist
                    String dp = null;
                    // if show == real then we can use show anyway cause there is only one value for both real and display; if show != real we care about show
                    int showDataProviders = valuelistPersist.getShowDataProviders();
                    if ((showDataProviders & 1) != 0) {
                        dp = valuelistPersist.getDataProviderID1();
                    }
                    if ((showDataProviders & 2) != 0) {
                        // display value is a concat of multiple columns, so a string; not even sure if format property makes sense, but it is for a String then
                        if (dp != null)
                            return ComponentFormat.getComponentFormat(formatValue, IColumnTypes.TEXT, application);
                        dp = valuelistPersist.getDataProviderID2();
                    }
                    if ((showDataProviders & 4) != 0) {
                        // display value is a concat of multiple columns, so a string; not even sure if format property makes sense, but it is for a String then
                        if (dp != null)
                            return ComponentFormat.getComponentFormat(formatValue, IColumnTypes.TEXT, application);
                        dp = valuelistPersist.getDataProviderID3();
                    }
                    if (dp != null) {
                        dataProvider = application.getFlattenedSolution().getDataProviderForTable(table, dp);
                    }
                    isValuelistFormatSet = true;
                    return ComponentFormat.getComponentFormat(formatValue, dataProvider, application, true);
                } else if (valuelistPersist.getValueListType() == IValueListConstants.CUSTOM_VALUES) {
                    IValueList realValuelist = null;
                    ValueListTypeSabloValue valuelistSabloValue = (ValueListTypeSabloValue) FoundsetLinkedTypeSabloValue.unwrapIfNeeded(webObjectContext.getProperty(propertyDependencies.valueListPropertyName));
                    if (valuelistSabloValue != null) {
                        // take it from property, may not be the shared instance in case setvaluelistitems on component was used
                        realValuelist = valuelistSabloValue.getValueList();
                    }
                    if (realValuelist == null) {
                        realValuelist = com.servoy.j2db.component.ComponentFactory.getRealValueList(application, valuelistPersist, true, Types.OTHER, ComponentFormat.getComponentFormat(formatValue, dataproviderId, null, application, true).parsedFormat, null, true);
                    }
                    if (realValuelist.hasRealValues()) {
                        // if custom vl has both real and display values, the display values are TEXT (format is for those)
                        // of if it has displayValueType set, use that
                        isValuelistFormatSet = true;
                        int realValueDisplayType = realValuelist.getValueList().getDisplayValueType();
                        return ComponentFormat.getComponentFormat(formatValue, realValueDisplayType != 0 ? realValueDisplayType : IColumnTypes.TEXT, application);
                    }
                } else if (valuelistPersist.getValueListType() == IValueListConstants.GLOBAL_METHOD_VALUES) {
                    PropertyDescription vlPD = webObjectCntxt.getPropertyDescription(propertyDependencies.valueListPropertyName);
                    Object vlPDConfig = null;
                    if (vlPD != null) {
                        vlPDConfig = vlPD.getConfig();
                        if (vlPDConfig instanceof FoundsetLinkedConfig)
                            vlPDConfig = ((FoundsetLinkedConfig) vlPDConfig).getWrappedConfig();
                    }
                    boolean lazyLoad = valuelistPersist.getLazyLoading() && vlPDConfig instanceof ValueListConfig && ((ValueListConfig) vlPDConfig).getLazyLoading();
                    if (!lazyLoad) {
                        IValueList realValuelist = com.servoy.j2db.component.ComponentFactory.getRealValueList(application, valuelistPersist, true, Types.OTHER, null, null, true);
                        if (realValuelist instanceof GlobalMethodValueList) {
                            ((GlobalMethodValueList) realValuelist).fill(null, "", null);
                            if (realValuelist.hasRealValues() || realValuelist.getSize() == 0 || (realValuelist.getSize() == 1 && valuelistPersist.getAddEmptyValue() == IValueListConstants.EMPTY_VALUE_ALWAYS)) {
                                // if global method vl has both real and display values, the display values are TEXT (format is for those)
                                // of if it has displayValueType set, use that
                                isValuelistFormatSet = true;
                                int realValueDisplayType = realValuelist.getValueList().getDisplayValueType();
                                return ComponentFormat.getComponentFormat(formatValue, realValueDisplayType != 0 ? realValueDisplayType : IColumnTypes.TEXT, application);
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Debug.error(ex);
            }
        }
    // here - we want to fall back to the dataprovider if available in for: [ ..., dataprovider] if valuelist didn't force a certain display type on the format
    }
    if (dataproviderId != null && foundsetId != null) {
        ITable table = null;
        Form form = ((IContextProvider) webObjectCntxt.getUnderlyingWebObject()).getDataConverterContext().getForm().getForm();
        // always assume now that the the properties has the foundset property name.
        FoundsetTypeSabloValue runtimeValOfFoundset = (FoundsetTypeSabloValue) webObjectCntxt.getUnderlyingWebObject().getProperty(this.propertyDependencies.foundsetPropertyName);
        if (runtimeValOfFoundset != null && runtimeValOfFoundset.getFoundset() != null && runtimeValOfFoundset.getFoundset().getDataSource().equals(foundsetId)) {
            table = runtimeValOfFoundset.getFoundset().getTable();
        }
        if (table == null)
            table = FoundsetTypeSabloValue.getTableBasedOfFoundsetPropertyFromFoundsetIdentifier(foundsetId, application, form);
        if (table != null) {
            dataProviderLookup = new FormAndTableDataProviderLookup(application.getFlattenedSolution(), form, table);
        }
    // else it will be searched for in form's context and table as below
    }
    if (dataProviderLookup == null) {
        WebObjectSpecification spec = ((WebFormComponent) webObjectCntxt.getUnderlyingWebObject()).getParent().getSpecification();
        if (spec != null) {
            Collection<PropertyDescription> formComponentProperties = spec.getProperties(FormComponentPropertyType.INSTANCE);
            if (formComponentProperties != null) {
                for (PropertyDescription property : formComponentProperties) {
                    if (property.getConfig() instanceof ComponentTypeConfig && ((ComponentTypeConfig) property.getConfig()).forFoundset != null) {
                        FoundsetTypeSabloValue runtimeValOfFoundset = (FoundsetTypeSabloValue) ((WebFormComponent) webObjectCntxt.getUnderlyingWebObject()).getParent().getProperty(((ComponentTypeConfig) property.getConfig()).forFoundset);
                        ITable table = null;
                        Form form = ((IContextProvider) webObjectCntxt.getUnderlyingWebObject()).getDataConverterContext().getForm().getForm();
                        if (runtimeValOfFoundset.getFoundset() != null)
                            table = runtimeValOfFoundset.getFoundset().getTable();
                        if (table == null)
                            table = FoundsetTypeSabloValue.getTableBasedOfFoundsetPropertyFromFoundsetIdentifier(runtimeValOfFoundset.getFoundsetSelector(), application, form);
                        if (table != null) {
                            dataProviderLookup = new FormAndTableDataProviderLookup(application.getFlattenedSolution(), form, table);
                        }
                        break;
                    }
                }
            }
        }
    }
    if (dataProviderLookup == null && application != null)
        dataProviderLookup = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), ((IContextProvider) webObjectCntxt.getUnderlyingWebObject()).getDataConverterContext().getForm().getForm());
    ComponentFormat format = ComponentFormat.getComponentFormat(formatValue, dataproviderId, dataProviderLookup, application, true);
    return format;
}
Also used : WebObjectSpecification(org.sablo.specification.WebObjectSpecification) ValueList(com.servoy.j2db.persistence.ValueList) GlobalMethodValueList(com.servoy.j2db.dataprocessing.GlobalMethodValueList) IValueList(com.servoy.j2db.dataprocessing.IValueList) Form(com.servoy.j2db.persistence.Form) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) FoundsetLinkedConfig(com.servoy.j2db.server.ngclient.property.FoundsetLinkedConfig) GlobalMethodValueList(com.servoy.j2db.dataprocessing.GlobalMethodValueList) IDataProvider(com.servoy.j2db.persistence.IDataProvider) Relation(com.servoy.j2db.persistence.Relation) INGApplication(com.servoy.j2db.server.ngclient.INGApplication) IContextProvider(com.servoy.j2db.server.ngclient.IContextProvider) FormAndTableDataProviderLookup(com.servoy.j2db.FormAndTableDataProviderLookup) ITable(com.servoy.j2db.persistence.ITable) ComponentTypeConfig(com.servoy.j2db.server.ngclient.property.ComponentTypeConfig) IValueList(com.servoy.j2db.dataprocessing.IValueList) ComponentFormat(com.servoy.j2db.component.ComponentFormat) ValueListConfig(com.servoy.j2db.server.ngclient.property.ValueListConfig) PropertyDescription(org.sablo.specification.PropertyDescription) FoundsetTypeSabloValue(com.servoy.j2db.server.ngclient.property.FoundsetTypeSabloValue) IDataProviderLookup(com.servoy.j2db.persistence.IDataProviderLookup)

Example 9 with INGApplication

use of com.servoy.j2db.server.ngclient.INGApplication in project servoy-client by Servoy.

the class JSEventType method fillJSEvent.

/**
 * @param event Event that needs to be filled
 * @param jsonObject The json data for that has the event data.
 * @param webObject The webObject element (WEbFormComponent or WebFormUI)
 * @param controller Optional the controller object if the caller knows this already
 * @return
 */
@SuppressWarnings("nls")
public static void fillJSEvent(JSBaseEvent event, JSONObject jsonObject, BaseWebObject webObject, IWebFormController controller) {
    event.setType(jsonObject.optString("eventType"));
    String formName = controller != null ? controller.getName() : "";
    String elementName = "";
    if (webObject instanceof WebFormComponent) {
        elementName = ((WebFormComponent) webObject).getFormElement().getRawName();
        if (elementName == null)
            elementName = "";
        if (formName.isEmpty()) {
            BaseWebObject parentWebObject = ((WebFormComponent) webObject).getParent();
            while (parentWebObject != null && !(parentWebObject instanceof WebFormUI)) {
                parentWebObject = ((WebFormComponent) parentWebObject).getParent();
            }
            if (parentWebObject instanceof WebFormUI) {
                formName = parentWebObject.getName();
            }
        }
    }
    if (formName.isEmpty()) {
        formName = jsonObject.optString("formName");
    }
    if (formName.isEmpty() && webObject instanceof WebFormUI) {
        // executeInlineScript with an event in params tells a DAL to execute it and it gives a formui as context to the fromJSON conversion
        // for JSEventType problem is that it can give any formName from the client (the component/service can give anything there as an arg); or, if the function
        // (sent to client before through "function" type) that will be used to execute the script is a global/scope function
        // then formName can be null and in that case the WebFormUI will be the main form or the window (not the most nested one)
        // so this is just a fallback and we do give priority to the form name determined on client through $window.createJSEvent(...) an put into
        // "jsonObject" (see if above) - to target the correct form - closest one to event
        formName = webObject.getName();
    }
    if (elementName.isEmpty()) {
        elementName = jsonObject.optString("elementName");
    }
    if (!formName.isEmpty())
        event.setFormName(formName);
    if (!elementName.isEmpty())
        event.setElementName(elementName);
    if (!formName.isEmpty()) {
        INGApplication application = ((IContextProvider) webObject).getDataConverterContext().getApplication();
        IWebFormController formController = controller != null ? controller : application.getFormManager().getForm(formName);
        if (formController != null) {
            FormScope formScope = formController.getFormScope();
            if (formScope != null) {
                ElementScope elementsScope = (ElementScope) formScope.get("elements", null);
                if (elementsScope != null) {
                    Object scriptableElement = !elementName.isEmpty() ? elementsScope.get(elementName, null) : null;
                    if (scriptableElement != null && scriptableElement != Scriptable.NOT_FOUND) {
                        event.setSource(scriptableElement);
                    } else if (webObject instanceof WebFormComponent) {
                        // quickly create a scriptable wrapper around the component so that the source can be set to a value that we expect.
                        FormElement fe = ((WebFormComponent) webObject).getFormElement();
                        RuntimeWebComponent runtimeComponent = new RuntimeWebComponent((WebFormComponent) webObject, webObject.getSpecification());
                        if (fe.isLegacy() || ((fe.getForm().getView() == IForm.LIST_VIEW || fe.getForm().getView() == FormController.LOCKED_LIST_VIEW || fe.getForm().getView() == FormController.TABLE_VIEW || fe.getForm().getView() == FormController.LOCKED_TABLE_VIEW) && fe.getTypeName().startsWith("svy-"))) {
                            // add legacy behavior
                            runtimeComponent.setPrototype(new RuntimeLegacyComponent((WebFormComponent) webObject));
                        }
                        event.setSource(runtimeComponent);
                    }
                }
            }
        }
    }
    try {
        if (jsonObject.has("x"))
            event.setLocation(new Point(jsonObject.optInt("x"), jsonObject.optInt("y")));
        if (jsonObject.has("modifiers"))
            event.setModifiers(jsonObject.optInt("modifiers"));
        if (jsonObject.has("data"))
            event.setData(jsonObject.opt("data"));
        if (jsonObject.has("timestamp"))
            event.setTimestamp(new Timestamp(jsonObject.getLong("timestamp")));
        else
            event.setTimestamp(new Date());
    } catch (Exception e) {
        Debug.error("error setting event properties from " + jsonObject + ", for component: " + elementName + " on form " + formName, e);
    }
}
Also used : WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) ElementScope(com.servoy.j2db.scripting.ElementScope) IWebFormController(com.servoy.j2db.server.ngclient.IWebFormController) Point(java.awt.Point) RuntimeWebComponent(com.servoy.j2db.server.ngclient.component.RuntimeWebComponent) Timestamp(java.sql.Timestamp) FormElement(com.servoy.j2db.server.ngclient.FormElement) Date(java.util.Date) JSONException(org.json.JSONException) BaseWebObject(org.sablo.BaseWebObject) FormScope(com.servoy.j2db.scripting.FormScope) WebFormUI(com.servoy.j2db.server.ngclient.WebFormUI) INGApplication(com.servoy.j2db.server.ngclient.INGApplication) JSONObject(org.json.JSONObject) BaseWebObject(org.sablo.BaseWebObject) RuntimeLegacyComponent(com.servoy.j2db.server.ngclient.component.RuntimeLegacyComponent)

Aggregations

INGApplication (com.servoy.j2db.server.ngclient.INGApplication)9 IValueList (com.servoy.j2db.dataprocessing.IValueList)3 ITable (com.servoy.j2db.persistence.ITable)3 ValueList (com.servoy.j2db.persistence.ValueList)3 IContextProvider (com.servoy.j2db.server.ngclient.IContextProvider)3 PropertyDescription (org.sablo.specification.PropertyDescription)3 FormAndTableDataProviderLookup (com.servoy.j2db.FormAndTableDataProviderLookup)2 CustomValueList (com.servoy.j2db.dataprocessing.CustomValueList)2 Form (com.servoy.j2db.persistence.Form)2 IDataProvider (com.servoy.j2db.persistence.IDataProvider)2 IDataProviderLookup (com.servoy.j2db.persistence.IDataProviderLookup)2 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)2 FoundsetLinkedConfig (com.servoy.j2db.server.ngclient.property.FoundsetLinkedConfig)2 JSONException (org.json.JSONException)2 FlattenedSolution (com.servoy.j2db.FlattenedSolution)1 ComponentFormat (com.servoy.j2db.component.ComponentFormat)1 DBValueList (com.servoy.j2db.dataprocessing.DBValueList)1 FindState (com.servoy.j2db.dataprocessing.FindState)1 FoundSetEvent (com.servoy.j2db.dataprocessing.FoundSetEvent)1 GlobalMethodValueList (com.servoy.j2db.dataprocessing.GlobalMethodValueList)1