Example usage for com.google.gwt.user.client Window addCloseHandler

List of usage examples for com.google.gwt.user.client Window addCloseHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window addCloseHandler.

Prototype

public static HandlerRegistration addCloseHandler(final CloseHandler<Window> handler) 

Source Link

Document

Adds a CloseEvent handler.

Usage

From source file:cc.alcina.extras.misc.ie.client.AugmentedUncaughtExceptionHandler.java

License:Apache License

public void registerUncaughtExceptionHandler(UncaughtExceptionHandler handler) {
    if (GWT.isScript() && BrowserMod.isInternetExplorer() && !BrowserMod.isIE10Plus()) {
        AugmentedUncaughtExceptionHandler.handler = handler;
        registerIEWindowErrorListener();
        Window.addCloseHandler(this);
        disableEventBusExceptionCatch();
    } else {/*from  w w w .  j  a v  a2s  .  c  o m*/
        GWT.setUncaughtExceptionHandler(handler);
    }
}

From source file:cc.alcina.framework.gwt.client.ClientBase.java

License:Apache License

public ClientBase() {
    if (GWT.isClient()) {
        initInitialTokenHandler();//from  w  w w.jav a 2 s .  c om
        if (!BrowserMod.isInternetExplorer()) {
            Window.addCloseHandler(this);
        }
    }
}

From source file:ccc.client.gwt.core.GWTWindow.java

License:Open Source License

/** {@inheritDoc} */
@Override/*from w w w .jav a 2 s. c  o  m*/
public void enableExitConfirmation() {
    _handlerRegistration = Window.addWindowClosingHandler(new ExitHandler());

    Window.addCloseHandler(new CloseHandler<Window>() {
        @Override
        public void onClose(final CloseEvent<Window> arg0) {
            new LogoutAction().execute();
        }
    });
}

From source file:com.allen_sauer.gwt.log.client.WindowLogger.java

License:Apache License

/**
 * Default constructor.
 */
public WindowLogger() {
    Window.addCloseHandler(windowCloseListener);
}

From source file:com.calclab.emite.browser.client.AutoConfig.java

License:Open Source License

private void prepareOnCloseAction(final String sessionBehaviour) {
    logger.finer("PageController - configuring close action...");
    Window.addCloseHandler(new CloseHandler<Window>() {
        @Override//from  w  ww . j  a  v a 2 s  .c  o m
        public void onClose(final CloseEvent<Window> arg0) {
            if (RESUME.equals(sessionBehaviour) || RESUME_OR_LOGIN.equals(sessionBehaviour)) {
                logger.info("PAUSING SESSION...");
                PageAssist.pauseSession(session);
            } else if (LOGIN.equals(sessionBehaviour)) {
                logger.info("LOGGIN OUT SESSION...");
                PageAssist.closeSession(session);
            } else if (LOGOUT.equals(sessionBehaviour)) {
                logger.info("LOGGIN OUT SESSION...");
                PageAssist.closeSession(session);
            }
        }
    });
}

From source file:com.gwos.client.ui.desktop.GwosDesktop.java

License:Apache License

private void setBrowserClosingHandler() {

    Window.addWindowClosingHandler(new Window.ClosingHandler() {
        @Override// w w  w  .  j av a 2 s.c  o  m
        public void onWindowClosing(ClosingEvent event) {
            if (SessionManager.getInstance().isUserLogged() == false) {
                return;
            }
            // Request confirmation to the user when he close his browser
            event.setMessage("Changes on your session will be lost. Are you sure ?");
        }
    });

    Window.addCloseHandler(new CloseHandler<Window>() {
        @Override
        public void onClose(CloseEvent<Window> event) {
            if (SessionManager.getInstance().isUserLogged() == false) {
                return;
            }
            // Before the browser is closed, save the session !
            SessionManager.getInstance().logout();
        }
    });
}

From source file:com.ponysdk.core.terminal.PonySDK.java

License:Apache License

private void startMainContext() {
    Window.addCloseHandler(event -> close());
    final String builder = GWT.getHostPageBaseURL().replaceFirst("http", "ws") + MappingPath.WEBSOCKET + "?"
            + ClientToServerModel.TYPE_HISTORY.toStringValue() + "=" + History.getToken();
    final ReconnectionChecker reconnectionChecker = new ReconnectionChecker();
    socketClient = new WebSocketClient(builder, uiBuilder, reconnectionChecker);

    reconnectionChecker.checkConnection();
}

From source file:com.pronoiahealth.olhie.client.features.impl.WindowCloseTrappingFeature.java

License:Open Source License

@Override
public boolean activate() {
    windowCloseHandler = Window.addCloseHandler(new CloseHandler<Window>() {
        @Override//w  w w. j ava2  s .  co m
        public void onClose(CloseEvent<Window> event) {
            if (clientUserToken.isLoggedIn() == true) {
                windowCloseTrapped();
            }
        }
    });

    return true;
}

From source file:de.swm.commons.mobile.client.orientation.OrientationController.java

License:Apache License

/**
 * Set up orientation support.//ww w . j a v  a2  s  .c  o m
 */
private static void setupOrientation() {

    if (!orientationSupport()) {
        Window.addResizeHandler(new ResizeHandler() {

            @Override
            public void onResize(ResizeEvent event) {
                Orientation orientation = getOrientation();
                if (orientation != currentOrientation) {
                    currentOrientation = orientation;
                    fireOrientationChangedEvent(orientation);
                }
            }
        });
    } else {
        nativeJsFunction = setupBrowserNativeOrientationSupport();
        Window.addCloseHandler(new CloseHandler<Window>() {

            @Override
            public void onClose(CloseEvent<Window> event) {
                destroyOrientation(nativeJsFunction);

            }
        });
    }

}

From source file:edu.caltech.ipac.firefly.core.Application.java

private void initAndShow() {

    // initialize JossoUtil... supply context information
    JossoUtil.init(Application.getInstance().getProperties().getProperty("sso.server.url"),
            GWT.getModuleBaseURL(),//from  www  .  jav  a 2s.  co m
            Application.getInstance().getProperties().getProperty("sso.user.profile.url"));

    commandTable = creator.makeCommandTable();
    toolBar = creator.getToolBar();
    layoutManager = creator.makeLayoutManager();
    if (creator.isApplication()) {
        requestHandler = getRequestHandler();
        History.addValueChangeHandler(requestHandler);
    }

    nullFrame = new Frame();
    nullFrame.setSize("0px", "0px");
    nullFrame.setVisible(false);

    RootPanel root = RootPanel.get();
    root.clear();
    root.add(nullFrame);
    if (BrowserUtil.isTouchInput())
        root.addStyleName("disable-select");

    if (getLayoutManager() != null)
        getLayoutManager().layout(creator.getLoadingDiv());

    checkMobilAppInstall();

    if (SupportedBrowsers.isSupported()) {
        if (appReady != null) {
            appReady.ready();
        }

        if (creator.isApplication()) {
            // save the current state when you leave.
            DeferredCommand.addCommand(new Command() {
                public void execute() {
                    Window.addCloseHandler(new CloseHandler<Window>() {
                        public void onClose(CloseEvent<Window> windowCloseEvent) {
                            gotoUrl(null, false);
                        }
                    });
                }
            });

            // coming back from prior session
            String ssoBackTo = Cookies.getCookie(PRIOR_STATE);
            final Request prevState = Request.parse(ssoBackTo);
            if (prevState != null && prevState.isSearchResult()) {
                Cookies.removeCookie(PRIOR_STATE);
                History.newItem(ssoBackTo, true);
            } else {
                // url contains request params
                String qs = Window.Location.getQueryString().replace("?", "");
                if (!StringUtils.isEmpty(qs) && !qs.contains(IGNORE_QUERY_STR)) {
                    String qsDecoded = URL.decodeQueryString(qs);
                    String base = Window.Location.getHref();
                    base = base.substring(0, base.indexOf("?"));
                    String newUrl = base + "#" + URL.encodePathSegment(qsDecoded);
                    Window.Location.replace(newUrl);
                } else {
                    String startToken = History.getToken();
                    if (StringUtils.isEmpty(startToken)) {
                        goHome();
                    } else {
                        requestHandler.processToken(startToken);
                    }
                }
            }
            if (backgroundMonitor != null)
                backgroundMonitor.syncWithCache(null);
        }
    } else {
        hideDefaultLoadingDiv();
        SupportedBrowsers.showUnsupportedMessage();
    }

}