Search in sources :

Example 1 with RuntimeSupportScriptProviders

use of com.servoy.j2db.FormController.RuntimeSupportScriptProviders in project servoy-client by Servoy.

the class FormScope method updateProviderswithCopy.

public void updateProviderswithCopy(Form originalForm, Form copyForm) {
    RuntimeSupportScriptProviders thisScope = (RuntimeSupportScriptProviders) getScriptLookup();
    thisScope.updateProviderwithCopy(originalForm, copyForm);
    for (LazyCompilationScope scope : extendScopes) {
        RuntimeSupportScriptProviders runtimeScriptProvider = (RuntimeSupportScriptProviders) scope.getScriptLookup();
        runtimeScriptProvider.updateProviderwithCopy(originalForm, copyForm);
    }
}
Also used : RuntimeSupportScriptProviders(com.servoy.j2db.FormController.RuntimeSupportScriptProviders)

Example 2 with RuntimeSupportScriptProviders

use of com.servoy.j2db.FormController.RuntimeSupportScriptProviders in project servoy-client by Servoy.

the class BasicFormController method initForJSUsage.

/**
 * Initialize this FormController(or related classes/methods) to be used in javascript
 */
public synchronized JSForm initForJSUsage(CreationalPrototype creationalPrototype) {
    if (formScope == null) {
        try {
            // make scope for state delegation via prototype mechanism
            List<Form> forms = application.getFlattenedSolution().getFormHierarchy(form);
            List<ISupportScriptProviders> scriptProviders = new ArrayList<ISupportScriptProviders>();
            for (Form frm : forms) {
                scriptProviders.add(new RuntimeSupportScriptProviders(application, frm));
            }
            formScope = new FormScope(this, scriptProviders.toArray(new ISupportScriptProviders[scriptProviders.size()]));
            if (formModel != null) {
                ITable formTable = application.getFoundSetManager().getTable(form.getDataSource());
                formScope.setPrototype(new SelectedRecordScope(this, formTable == null ? null : application.getScriptEngine().getTableScope(formTable)));
                // $NON-NLS-1$
                formScope.putWithoutFireChange("foundset", formModel);
            }
            // create JS place holder for this object
            scriptableForm = new BasicFormController.JSForm(this);
            // set parent scope
            NativeJavaObject formObject = new NativeJavaObject(formScope, scriptableForm, ScriptObjectRegistry.getJavaMembers(FormController.JSForm.class, formScope));
            // $NON-NLS-1$
            formScope.putWithoutFireChange("controller", formObject);
            // register the place holder 'scriptableForm' in CreationalPrototype scope
            creationalPrototype.setLocked(false);
            // $NON-NLS-1$
            creationalPrototype.put(((Integer) creationalPrototype.get("length", creationalPrototype)).intValue(), creationalPrototype, formScope);
            creationalPrototype.put(getName(), creationalPrototype, formScope);
            creationalPrototype.setLocked(true);
            formScope.createVars();
        } catch (Exception ex) {
            // $NON-NLS-1$
            application.reportError(application.getI18NMessage("servoy.formPanel.error.initFormScope") + ": " + getName(), ex);
            return null;
        }
    }
    return scriptableForm;
}
Also used : Form(com.servoy.j2db.persistence.Form) ArrayList(java.util.ArrayList) ServoyException(com.servoy.j2db.util.ServoyException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) FormScope(com.servoy.j2db.scripting.FormScope) ISupportScriptProviders(com.servoy.j2db.persistence.ISupportScriptProviders) RuntimeSupportScriptProviders(com.servoy.j2db.FormController.RuntimeSupportScriptProviders) SelectedRecordScope(com.servoy.j2db.scripting.SelectedRecordScope) ITable(com.servoy.j2db.persistence.ITable) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ITwoNativeJavaObject(com.servoy.j2db.scripting.ITwoNativeJavaObject)

Aggregations

RuntimeSupportScriptProviders (com.servoy.j2db.FormController.RuntimeSupportScriptProviders)2 Form (com.servoy.j2db.persistence.Form)1 ISupportScriptProviders (com.servoy.j2db.persistence.ISupportScriptProviders)1 ITable (com.servoy.j2db.persistence.ITable)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 FormScope (com.servoy.j2db.scripting.FormScope)1 ITwoNativeJavaObject (com.servoy.j2db.scripting.ITwoNativeJavaObject)1 SelectedRecordScope (com.servoy.j2db.scripting.SelectedRecordScope)1 ServoyException (com.servoy.j2db.util.ServoyException)1 ArrayList (java.util.ArrayList)1 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)1