Search in sources :

Example 1 with IFormController

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

the class AlwaysRowSelectedSelectionModel method testStopUIEditing.

private boolean testStopUIEditing() {
    for (IFormController fco : formControllers.toArray(new IFormController[formControllers.size()])) {
        if (fco.isFormVisible()) {
            EditRecordList editRecordList = fco.getApplication().getFoundSetManager().getEditRecordList();
            IRecord[] editedRecords = editRecordList.getEditedRecords(fco.getFoundSet());
            if (editedRecords.length > 0) {
                int stopEditing = editRecordList.stopEditing(false, Arrays.asList(editedRecords));
                return stopEditing == ISaveConstants.STOPPED || stopEditing == ISaveConstants.AUTO_SAVE_BLOCKED;
            }
        }
    }
    return true;
}
Also used : EditRecordList(com.servoy.j2db.dataprocessing.EditRecordList) IRecord(com.servoy.j2db.dataprocessing.IRecord) IFormController(com.servoy.j2db.IFormController)

Example 2 with IFormController

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

the class DebugJ2DBClient method destroyForm.

/**
 * @param formController
 * @return
 */
private void destroyForm(IFormController formController) {
    refreshI18NMessages(true);
    if (formController.isFormVisible()) {
        IFoundSetInternal foundSet = formController.getFormModel();
        if (foundSet instanceof FoundSet) {
            ((FoundSet) foundSet).refresh();
        }
        String name = null;
        if (formController.getForm() != null)
            name = formController.getForm().getName();
        if (name == null)
            name = formController.getName();
        if (getFormManager().getCurrentForm() == formController) {
            formController.destroy();
            getFormManager().showFormInCurrentContainer(name);
        } else {
            SwingForm swingForm = (SwingForm) formController.getFormUI();
            Container container = swingForm.getParent();
            boolean isNavigator = false;
            boolean isWindow = false;
            boolean isLookupPanel = false;
            if (container instanceof MainPanel) {
                isNavigator = ((MainPanel) container).getNavigator() == formController;
            } else if (container instanceof FormLookupPanel) {
                isLookupPanel = true;
            } else {
                while (container != null && !(container instanceof FormWindow)) {
                    container = container.getParent();
                }
                if (container instanceof FormWindow) {
                    isWindow = true;
                }
            }
            formController.destroy();
            if (isLookupPanel) {
                FormLookupPanel flp = (FormLookupPanel) container;
                FormController newFormController = flp.getFormPanel();
                if (newFormController != null) {
                    // deleted in developer ?
                    newFormController.loadData(foundSet, null);
                    List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
                    newFormController.notifyVisible(true, invokeLaterRunnables);
                    Utils.invokeLater(this, invokeLaterRunnables);
                }
            } else if (isNavigator) {
                // TODO isNavigator check will always be false for NGClient?
                FormController navigator = ((FormManager) getFormManager()).getFormController(name, container);
                if (navigator != null) {
                    navigator.loadData(foundSet, null);
                    List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
                    navigator.notifyVisible(true, invokeLaterRunnables);
                    Utils.invokeLater(this, invokeLaterRunnables);
                }
                mainPanel.setNavigator(navigator);
            } else if (isWindow) {
                // TODO isWindow check will always be false for NGClient?
                FormWindow w = (FormWindow) container;
                ((FormManager) getFormManager()).showFormInMainPanel(name, w.getMainContainer(), w.getTitle(), false, w.getName());
            }
        }
    } else {
        formController.destroy();
    }
    return;
}
Also used : IFormController(com.servoy.j2db.IFormController) FormController(com.servoy.j2db.FormController) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) ArrayList(java.util.ArrayList) FoundSet(com.servoy.j2db.dataprocessing.FoundSet) FormWindow(com.servoy.j2db.FormWindow) SwingForm(com.servoy.j2db.smart.SwingForm) IMainContainer(com.servoy.j2db.IMainContainer) Container(java.awt.Container) MainPanel(com.servoy.j2db.smart.MainPanel) FormManager(com.servoy.j2db.FormManager) SwingFormManager(com.servoy.j2db.smart.SwingFormManager) ArrayList(java.util.ArrayList) List(java.util.List) FormLookupPanel(com.servoy.j2db.smart.dataui.FormLookupPanel)

Example 3 with IFormController

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

the class DebugNGClient method refreshPersists.

@Override
public void refreshPersists(Collection<IPersist> changes) {
    if (isShutDown())
        return;
    // flush the solution model cache of the form element helper when there is a solution copy.
    // so that FormComponents are recreated with the latest data once.
    Solution solutionCopy = getFlattenedSolution().getSolutionCopy(false);
    if (solutionCopy != null)
        solutionCopy.setRuntimeProperty(FormElementHelper.SOLUTION_MODEL_CACHE, null);
    Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
    for (IFormController controller : scopesAndFormsToReload[1]) {
        if (controller.getForm() instanceof FlattenedForm) {
            FlattenedForm ff = (FlattenedForm) controller.getForm();
            ff.reload();
        }
    }
    boolean forcePageReload = false;
    if (scopesAndFormsToReload[1] == null || scopesAndFormsToReload[1].size() < 1) {
        for (IPersist persist : changes) {
            // that one, can also have other css included, using the 'import' statement
            if (persist instanceof Media && !PersistHelper.getOrderedStyleSheets(getFlattenedSolution()).isEmpty()) {
                String name = ((Media) persist).getName().toLowerCase();
                if (name.endsWith(".less") || name.endsWith(".css")) {
                    forcePageReload = true;
                    break;
                }
            }
        }
    }
    refreshForms(scopesAndFormsToReload[1], forcePageReload);
    for (IFormController controller : scopesAndFormsToReload[0]) {
        controller.getFormScope().reload();
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Set(java.util.Set) IPersist(com.servoy.j2db.persistence.IPersist) Media(com.servoy.j2db.persistence.Media) IFormController(com.servoy.j2db.IFormController) Solution(com.servoy.j2db.persistence.Solution)

Example 4 with IFormController

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

the class DebugWebClient method performRefresh.

private void performRefresh(List<IPersist> changes) {
    Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
    for (IFormController controller : scopesAndFormsToReload[0]) {
        if (controller.getForm() instanceof FlattenedForm) {
            FlattenedForm ff = (FlattenedForm) controller.getForm();
            ff.reload();
        }
        controller.getFormScope().reload();
    }
    if (scopesAndFormsToReload[1].size() > 0)
        ((WebFormManager) getFormManager()).reload((scopesAndFormsToReload[1]).toArray(new FormController[0]));
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Set(java.util.Set) IFormController(com.servoy.j2db.IFormController)

Example 5 with IFormController

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

the class JSForm method removeVariableFromScopes.

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

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