use of com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows in project servoy-client by Servoy.
the class NGClientEndpoint method handleException.
@Override
protected void handleException(final Exception e, final IWebsocketSession session) {
if (e instanceof ApplicationException) {
final ApplicationException ae = (ApplicationException) e;
// if the current window has no endpoint then quickly set it to this instance.
if (CurrentWindow.exists() && !CurrentWindow.get().hasEndpoint())
CurrentWindow.get().setEndpoint(this);
CurrentWindow.runForWindow(new NGClientWebsocketSessionWindows((INGClientWebsocketSession) session), new Runnable() {
@Override
public void run() {
if (ae.getErrorCode() == ServoyException.NO_LICENSE) {
session.getClientService("$sessionService").executeAsyncServiceCall("setNoLicense", new Object[] { getLicenseAndMaintenanceDetail() });
} else if (ae.getErrorCode() == ServoyException.MAINTENANCE_MODE) {
session.getClientService("$sessionService").executeAsyncServiceCall("setMaintenanceMode", new Object[] { getLicenseAndMaintenanceDetail() });
}
}
});
}
try {
((NGClient) ((INGClientWebsocketSession) session).getClient()).shutDown(true);
} catch (Exception e1) {
Debug.error("Error calling shutdown on client that had an exception when starting up: " + e.getMessage(), e1);
}
}
use of com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows 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);
}
}
}
use of com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows in project servoy-client by Servoy.
the class NGClient method overrideStyleSheet.
@Override
public void overrideStyleSheet(String oldStyleSheet, String newStyleSheet) {
overrideStyleSheets.put(oldStyleSheet, newStyleSheet);
Runnable runnable = new Runnable() {
@Override
public void run() {
getWebsocketSession().sendStyleSheet();
}
};
// make sure we report this on all windows.
if (CurrentWindow.exists() && CurrentWindow.get() instanceof WebsocketSessionWindows) {
runnable.run();
} else {
CurrentWindow.runForWindow(new NGClientWebsocketSessionWindows(getWebsocketSession()), runnable);
}
}
use of com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows in project servoy-client by Servoy.
the class NGClient method closeSolution.
@Override
public boolean closeSolution(boolean force, Object[] args) {
String currentSolution = isSolutionLoaded() ? getSolutionName() : null;
boolean isCloseSolution = super.closeSolution(force, args);
if (isCloseSolution) {
getRuntimeProperties().put(IServiceProvider.RT_VALUELIST_CACHE, null);
if (args == null || args.length < 1) {
if (!force && showUrl == null) {
CurrentWindow.runForWindow(new NGClientWebsocketSessionWindows(getWebsocketSession()), new Runnable() {
public void run() {
getWebsocketSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("reload", new Object[0]);
}
});
}
} else {
String openSolution = getPreferedSolutionNameToLoadOnInit();
if (openSolution == null)
openSolution = currentSolution;
if (openSolution != null) {
String m = getPreferedSolutionMethodNameToCall();
Object[] a = getPreferedSolutionMethodArguments();
StringBuilder url = new StringBuilder("solutions/").append(openSolution).append("/index.html");
if (m != null) {
url.append("?m=").append(m);
}
if (a != null && a.length > 0) {
url.append(m != null ? "&" : "?");
url.append("a=").append(a[0]);
}
showURL(url.toString(), "_self", null, 0, true);
}
}
}
return isCloseSolution;
}
use of com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows in project servoy-client by Servoy.
the class WebFormController method recreateUI.
@Override
public boolean recreateUI() {
Form oldForm = form;
// update flattened form reference cause now we probably need to use a SM modified version
Form f = application.getFlattenedSolution().getForm(form.getName());
// don't use cached, make sure it updates the cache
form = application.getFlattenedSolution().getFlattenedForm(f, false);
INGClientWindow allWindowsProxy = new NGClientWebsocketSessionWindows(getApplication().getWebsocketSession());
if (allWindowsProxy.hasFormChangedSinceLastSendToClient(form, getName())) {
// hide all visible children; here is an example that explains why it's needed:
// parent form has tabpanel with child1 and child2; child2 is visible (second tab)
// if you recreateUI on parent, child1 would turn out visible after recreateUI without a hide event on child2 if we wouldn't do the notifyVisible below;
// but also when you would afterwards change tab to child2 it's onShow won't be called because it thinks it's still visible which is strange;
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
notifyVisibleOnChildren(false, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
tabSequence = null;
f = application.getFlattenedSolution().getForm(form.getName());
form = application.getFlattenedSolution().getFlattenedForm(f);
getFormUI().init();
getApplication().recreateForm(form, getName());
if (isFormVisible) {
invokeLaterRunnables = new ArrayList<Runnable>();
notifyVisibleOnChildren(true, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (getDesignModeCallbacks() != null) {
// this form is in design mode, let the client know the ui is created:
RuntimeWebComponent[] components = getWebComponentElements();
String[] names = new String[components.length];
for (int i = 0; i < names.length; i++) {
names[i] = components[i].getComponent().getName();
}
getApplication().getWebsocketSession().getClientService(ClientDesignService.NAME).executeAsyncServiceCall("recreateUI", new Object[] { getName(), names });
}
}
} else {
// in case it's not already loaded on client side - so we can't rely on endpoint URL differeces - but it is modified by Solution Model and recreateUI is called, it's formUI needs to reinitialize as well
if ((oldForm != form || application.isInDeveloper()) && !allWindowsProxy.hasForm(getName())) {
tabSequence = null;
getFormUI().init();
Debug.trace("RecreateUI on form " + getName() + " only recreated form ui on server, because that form is not present client-side...");
} else
Debug.trace("RecreateUI on form " + getName() + " was ignored because that form was not changed or at least not since last being sent to client...");
}
application.getFlattenedSolution().deregisterLiveForm(form, namedInstance);
application.getFlattenedSolution().registerLiveForm(form, namedInstance);
return true;
}
Aggregations