Search in sources :

Example 6 with WebFormUI

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

the class DebugNGClient method refreshForms.

private void refreshForms(Collection<IFormController> forms, boolean forcePageReload) {
    boolean reload = forcePageReload;
    if (forms != null && forms.size() > 0) {
        reload = true;
        List<IFormController> cachedFormControllers = getFormManager().getCachedFormControllers();
        for (IFormController formController : cachedFormControllers) {
            if (formController.getFormUI() instanceof WebFormUI) {
                ((WebFormUI) formController.getFormUI()).clearCachedFormElements();
            }
        }
        // should we also use these?
        List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
        for (IFormController controller : forms) {
            boolean isVisible = controller.isFormVisible();
            if (isVisible)
                controller.notifyVisible(false, invokeLaterRunnables);
            if (controller.getFormModel() != null && !Utils.stringSafeEquals(controller.getDataSource(), controller.getFormModel().getDataSource())) {
                // for now we just destroy the form and recreate it with the other datasource;
                // TODO we just load the shared foundset for that datasource - can we improve this somehow so that the loaded foundset is closer to the current runtime situation of the form? (related tabs etc.)
                String name = controller.getName();
                controller.destroy();
                controller = getFormManager().leaseFormPanel(name);
                IFoundSetInternal foundset;
                try {
                    foundset = getFoundSetManager().getSharedFoundSet(controller.getDataSource());
                    foundset.loadAllRecords();
                    controller.loadRecords(foundset);
                } catch (ServoyException e) {
                    Debug.error(e);
                }
            } else {
                if (!controller.isDestroyed())
                    ((WebFormController) controller).initFormUI();
            }
            if (isVisible)
                controller.notifyVisible(true, invokeLaterRunnables);
        }
    }
    if (reload) {
        WebsocketSessionWindows allendpoints = new NGClientWebsocketSessionWindows(getWebsocketSession());
        allendpoints.executeAsyncServiceCall(getWebsocketSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE), "reload", null, null);
        try {
            allendpoints.flush();
        } catch (IOException e) {
            reportError("error sending changes to the client", e);
        }
    }
}
Also used : IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) NGClientWebsocketSessionWindows(com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ServoyException(com.servoy.j2db.util.ServoyException) NGClientWebsocketSessionWindows(com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows) WebsocketSessionWindows(org.sablo.eventthread.WebsocketSessionWindows) WebFormUI(com.servoy.j2db.server.ngclient.WebFormUI) IFormController(com.servoy.j2db.IFormController)

Aggregations

WebFormUI (com.servoy.j2db.server.ngclient.WebFormUI)6 FormElement (com.servoy.j2db.server.ngclient.FormElement)4 IFormController (com.servoy.j2db.IFormController)2 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)2 Point (java.awt.Point)2 Container (org.sablo.Container)2 BasicFormManager (com.servoy.j2db.BasicFormManager)1 CustomValueList (com.servoy.j2db.dataprocessing.CustomValueList)1 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)1 IValueList (com.servoy.j2db.dataprocessing.IValueList)1 Field (com.servoy.j2db.persistence.Field)1 Form (com.servoy.j2db.persistence.Form)1 IFormElement (com.servoy.j2db.persistence.IFormElement)1 IPersist (com.servoy.j2db.persistence.IPersist)1 ISupportAnchors (com.servoy.j2db.persistence.ISupportAnchors)1 Part (com.servoy.j2db.persistence.Part)1 ValueList (com.servoy.j2db.persistence.ValueList)1 ElementScope (com.servoy.j2db.scripting.ElementScope)1 FormScope (com.servoy.j2db.scripting.FormScope)1 FormComponentCache (com.servoy.j2db.server.ngclient.FormElementHelper.FormComponentCache)1