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);
}
}
}
Aggregations