Search in sources :

Example 6 with IFormController

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

the class JSForm method addVariableToScopes.

private void addVariableToScopes(ScriptVariable var) {
    List<IFormController> controllers = application.getFormManager().getCachedFormControllers(getForm());
    for (IFormController formController : controllers) {
        FormScope formScope = formController.getFormScope();
        formScope.put(var, true);
    }
}
Also used : IFormController(com.servoy.j2db.IFormController) FormScope(com.servoy.j2db.scripting.FormScope)

Example 7 with IFormController

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

the class JSForm method refreshFromScopes.

private void refreshFromScopes() {
    List<IFormController> controllers = application.getFormManager().getCachedFormControllers(getForm());
    for (IFormController formController : controllers) {
        FormScope formScope = formController.getFormScope();
        formScope.updateProviderswithCopy(getForm(), getForm());
        formScope.reload();
    }
}
Also used : IFormController(com.servoy.j2db.IFormController) FormScope(com.servoy.j2db.scripting.FormScope)

Example 8 with IFormController

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

the class JSForm method checkModification.

@Override
public final void checkModification() {
    // make copy if needed
    if (!isCopy) {
        setForm(application.getFlattenedSolution().createPersistCopy(getForm()));
        application.getFormManager().addForm(getForm(), false);
        // forms scope still uses the old copy of Script Providers
        Form oldform = getForm();
        List<IFormController> controllers = application.getFormManager().getCachedFormControllers(getForm());
        for (IFormController formController : controllers) {
            FormScope formScope = formController.getFormScope();
            formScope.updateProviderswithCopy(oldform, getForm());
        }
        isCopy = true;
    } else {
        application.getFlattenedSolution().flushFlattendFormCache(getForm(), true);
    }
    getForm().setLastModified(System.currentTimeMillis());
    application.getFlattenedSolution().registerChangedForm(getForm());
    useFormCache = false;
}
Also used : Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IMobileSMForm(com.servoy.base.solutionmodel.mobile.IMobileSMForm) IFormController(com.servoy.j2db.IFormController) FormScope(com.servoy.j2db.scripting.FormScope)

Example 9 with IFormController

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

the class NGFormManager method destroySolutionSettings.

protected void destroySolutionSettings(boolean reload) {
    loginForm = null;
    for (IFormController controller : createdFormControllers.values()) {
        controller.destroy();
        hideFormIfVisible(controller);
    }
    clearLeaseHistory();
    possibleForms.clear();
    scriptingReadonlyStates.clear();
    // cleanup windows (containers)
    NGRuntimeWindowManager wm = ((INGApplication) application).getRuntimeWindowManager();
    wm.destroy(reload);
}
Also used : IFormController(com.servoy.j2db.IFormController)

Example 10 with IFormController

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

the class NGFormManager method showFormInContainer.

@Override
public IFormController showFormInContainer(String formName, IBasicMainContainer container, String title, boolean closeAll, String dialogName) {
    if (loginForm != null && loginForm.getName() != formName) {
        // not allowed to leave here...or show anything else than login form
        return null;
    }
    // $NON-NLS-1$
    if (formName == null)
        throw new IllegalArgumentException(application.getI18NMessage("servoy.formManager.error.SettingVoidForm"));
    IFormController currentMainShowingForm = container.getController();
    boolean sameForm = (currentMainShowingForm != null && formName.equals(currentMainShowingForm.getName()));
    if (sameForm && currentMainShowingForm.isFormVisible())
        return leaseFormPanel(currentMainShowingForm.getName());
    final Form f = possibleForms.get(formName);
    if (f == null) {
        return null;
    }
    try {
        int access = application.getFlattenedSolution().getSecurityAccess(f.getUUID(), f.getImplicitSecurityNoRights() ? IRepository.IMPLICIT_FORM_NO_ACCESS : IRepository.IMPLICIT_FORM_ACCESS);
        if (access != -1) {
            boolean b_visible = ((access & IRepository.VIEWABLE) != 0);
            if (!b_visible) {
                // $NON-NLS-1$
                application.reportWarningInStatus(application.getI18NMessage("servoy.formManager.warningAccessForm"));
                return null;
            }
        }
        // handle old panel
        if (currentMainShowingForm != null) {
            // leave forms in browse mode // TODO can this be set if notifyVisible returns false (current form is being kept)
            if (application.getModeManager().getMode() != IModeManager.EDIT_MODE) {
                application.getModeManager().setMode(IModeManager.EDIT_MODE);
            }
            IWebFormController fp = leaseFormPanel(currentMainShowingForm.getName());
            if (fp != null && !sameForm) {
                List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
                boolean ok = fp.notifyVisible(false, invokeLaterRunnables);
                if (invokeLaterRunnables.size() > 0)
                    wrapInShowLoadingIndicator(invokeLaterRunnables);
                Utils.invokeLater(application, invokeLaterRunnables);
                // solution closed in onhide method of previous form?
                if (application.getSolution() == null)
                    return null;
                if (!ok) {
                    return fp;
                }
            }
        }
        // set main
        IFormController tmpForm = currentMainShowingForm;
        final IWebFormController fp = leaseFormPanel(formName);
        currentMainShowingForm = fp;
        if (fp != null) {
            // test if solution is closed in the onload method.
            if (application.getSolution() == null)
                return null;
            setCurrentControllerJS(fp);
            // add to history
            getHistory(container).add(fp.getName());
            container.setController(fp);
            // show panel as main
            List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
            fp.notifyVisible(true, invokeLaterRunnables);
            String titleText = title;
            if (titleText == null)
                titleText = f.getTitleText();
            // $NON-NLS-1$
            if (titleText == null || titleText.equals(""))
                titleText = fp.getName();
            // $NON-NLS-1$
            if (NO_TITLE_TEXT.equals(titleText))
                titleText = "";
            container.setTitle(titleText);
            fp.getFormUI().setParentWindowName(container.getContainerName());
            if (invokeLaterRunnables.size() > 0)
                wrapInShowLoadingIndicator(invokeLaterRunnables);
            Utils.invokeLater(application, invokeLaterRunnables);
        } else {
            container.setController(null);
        }
        // $NON-NLS-1$
        J2DBGlobals.firePropertyChange(this, "form", tmpForm, currentMainShowingForm);
        return fp;
    } catch (Exception e) {
        Debug.error(e);
    }
    return null;
}
Also used : Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) ArrayList(java.util.ArrayList) IFormController(com.servoy.j2db.IFormController)

Aggregations

IFormController (com.servoy.j2db.IFormController)26 ArrayList (java.util.ArrayList)8 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)6 FormScope (com.servoy.j2db.scripting.FormScope)6 Form (com.servoy.j2db.persistence.Form)5 Set (java.util.Set)5 IPersist (com.servoy.j2db.persistence.IPersist)4 Solution (com.servoy.j2db.persistence.Solution)4 List (java.util.List)3 IApplication (com.servoy.j2db.IApplication)2 IBasicFormManager (com.servoy.j2db.IBasicFormManager)2 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)2 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)2 WebFormUI (com.servoy.j2db.server.ngclient.WebFormUI)2 ServoyException (com.servoy.j2db.util.ServoyException)2 HashMap (java.util.HashMap)2 IMobileSMForm (com.servoy.base.solutionmodel.mobile.IMobileSMForm)1 BasicFormManager (com.servoy.j2db.BasicFormManager)1 FormController (com.servoy.j2db.FormController)1 FormManager (com.servoy.j2db.FormManager)1