Search in sources :

Example 1 with IWindow

use of org.sablo.websocket.IWindow in project servoy-client by Servoy.

the class NGClientWebsocketSession method sendRedirect.

public void sendRedirect(final String redirectUrl) {
    IWindow curr = CurrentWindow.safeGet();
    CurrentWindow.runForWindow(curr != null && redirectUrl != null ? curr : new NGClientWebsocketSessionWindows(client.getWebsocketSession()), new Runnable() {

        @Override
        public void run() {
            Map<String, Object> detail = new HashMap<>();
            String htmlfilePath = Settings.getInstance().getProperty("servoy.webclient.pageexpired.page");
            if (htmlfilePath != null)
                detail.put("viewUrl", htmlfilePath);
            if (redirectUrl != null)
                detail.put("redirectUrl", redirectUrl);
            getClientService("$sessionService").executeAsyncServiceCall("expireSession", new Object[] { detail });
        }
    });
}
Also used : NGClientWebsocketSessionWindows(com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows) JSONObject(org.json.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap) IWindow(org.sablo.websocket.IWindow)

Example 2 with IWindow

use of org.sablo.websocket.IWindow in project servoy-client by Servoy.

the class WebFormUI method destroy.

@Override
public void destroy() {
    if (dataAdapterList != null)
        dataAdapterList.destroy();
    Collection<WebComponent> componentsList = new ArrayList<WebComponent>(getComponents());
    for (WebComponent c : componentsList) {
        c.dispose();
    }
    clearComponents();
    cleanupListeners();
    IWindow window = CurrentWindow.safeGet();
    if (window != null)
        window.unregisterContainer(this);
}
Also used : WebComponent(org.sablo.WebComponent) RuntimeWebComponent(com.servoy.j2db.server.ngclient.component.RuntimeWebComponent) ArrayList(java.util.ArrayList) IWindow(org.sablo.websocket.IWindow)

Example 3 with IWindow

use of org.sablo.websocket.IWindow in project servoy-client by Servoy.

the class RuntimeWebComponent method isApiFunctionEnabled.

protected boolean isApiFunctionEnabled(String functionName) {
    boolean isLocationOrSize = "getLocationX".equals(functionName) || "getLocationY".equals(functionName) || "getWidth".equals(functionName) || "getHeight".equals(functionName);
    if (isLocationOrSize) {
        // if parent form not visible, don't call api, let it get from the model on the server
        Container parent = component.getParent();
        while (parent != null) {
            if (parent instanceof WebFormUI) {
                boolean isFormVisible = false;
                IWindow currentWindow = CurrentWindow.safeGet();
                if (currentWindow instanceof INGClientWindow) {
                    isFormVisible = ((INGClientWindow) currentWindow).hasForm(parent.getName());
                }
                if (isFormVisible) {
                    // it is reported to be still on the client
                    // but do check also if it is not about to be hidden, by having
                    // formVisible already set to false in the controller
                    isFormVisible = ((WebFormUI) parent).getController().isFormVisible();
                }
                if (!isFormVisible) {
                    return false;
                }
                // if this form is in designer mode then it has to go to the client to get the current size/location
                if (((WebFormUI) parent).getController().getDesignModeCallbacks() != null)
                    return true;
                break;
            }
            parent = parent.getParent();
        }
        // if it is not table view (it can have columns moved/resize) and not anchored, no need to call api, let it get from the model on the server
        FormElement fe = component.getFormElement();
        if (fe.isLegacy() && fe.getPersistIfAvailable() instanceof ISupportAnchors && (fe.getForm().getView() != FormController.TABLE_VIEW && fe.getForm().getView() != FormController.LOCKED_TABLE_VIEW)) {
            // ((ISupportAnchors)fe.getPersistIfAvailable()).getAnchors();
            int anchor = Utils.getAsInteger(component.getProperty(StaticContentSpecLoader.PROPERTY_ANCHORS.getPropertyName()));
            if ((anchor == 0 || anchor == (IAnchorConstants.NORTH + IAnchorConstants.WEST))) {
                return false;
            }
        }
    }
    return true;
}
Also used : Container(org.sablo.Container) ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) IWebFormUI(com.servoy.j2db.server.ngclient.IWebFormUI) WebFormUI(com.servoy.j2db.server.ngclient.WebFormUI) INGClientWindow(com.servoy.j2db.server.ngclient.INGClientWindow) IWindow(org.sablo.websocket.IWindow) FormElement(com.servoy.j2db.server.ngclient.FormElement)

Example 4 with IWindow

use of org.sablo.websocket.IWindow in project servoy-client by Servoy.

the class WebFormController method destroy.

@Override
public void destroy() {
    if (isFormVisible() && application.isSolutionLoaded()) {
        destroyOnHide = true;
    } else {
        try {
            unload();
            if (formUI != null) {
                formUI.destroy();
                formUI = null;
            }
            super.destroy();
            IWindow window = CurrentWindow.safeGet();
            if (window instanceof INGClientWindow && application.isSolutionLoaded()) {
                ((INGClientWindow) window).destroyForm(getName());
            }
            if (getBasicFormManager() != null)
                getBasicFormManager().removeFormController(this);
        } finally {
            application.getFlattenedSolution().deregisterLiveForm(form, namedInstance);
        }
    }
}
Also used : INGClientWindow(com.servoy.j2db.server.ngclient.INGClientWindow) IWindow(org.sablo.websocket.IWindow)

Aggregations

IWindow (org.sablo.websocket.IWindow)4 INGClientWindow (com.servoy.j2db.server.ngclient.INGClientWindow)2 ISupportAnchors (com.servoy.j2db.persistence.ISupportAnchors)1 FormElement (com.servoy.j2db.server.ngclient.FormElement)1 IWebFormUI (com.servoy.j2db.server.ngclient.IWebFormUI)1 WebFormUI (com.servoy.j2db.server.ngclient.WebFormUI)1 RuntimeWebComponent (com.servoy.j2db.server.ngclient.component.RuntimeWebComponent)1 NGClientWebsocketSessionWindows (com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JSONObject (org.json.JSONObject)1 Container (org.sablo.Container)1 WebComponent (org.sablo.WebComponent)1