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

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

Introduction

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

Prototype

public static HandlerRegistration addWindowClosingHandler(final ClosingHandler handler) 

Source Link

Document

Adds a Window.ClosingEvent handler.

Usage

From source file:cc.alcina.framework.gwt.persistence.client.ClientSession.java

License:Apache License

protected void init() {
    Window.addWindowClosingHandler((ClosingHandler) this);
    setAppId("alcina");
}

From source file:cc.kune.core.client.init.AppStarterDefault.java

License:GNU Affero Public License

/**
 * Instantiates a new app starter default.
 * //from  w w w  .ja v a  2 s .co m
 * @param session
 *          the session
 * @param siteService
 *          the site service
 * @param eventBus
 *          the event bus
 * @param prefetchUtilities
 *          the prefetch utilities
 * @param res
 *          the res
 */
@Inject
public AppStarterDefault(final Session session, final SiteServiceAsync siteService, final EventBus eventBus,
        final PrefetchUtilities prefetchUtilities, final CommonResources res) {
    this.session = session;
    this.siteService = siteService;
    this.eventBus = eventBus;
    this.prefetchUtilities = prefetchUtilities;
    this.res = res;
    Window.addWindowClosingHandler(new ClosingHandler() {
        @Override
        public void onWindowClosing(final ClosingEvent event) {
            eventBus.fireEvent(new AppStopEvent());
        }
    });
}

From source file:cc.kune.wave.client.CustomSavedStateIndicator.java

License:Open Source License

/**
 * Simple saved state indicator.//from ww w.  j  a v a2s.c om
 *
 * @author danilatos@google.com (Daniel Danilatos)
 * @author yurize@apache.org (Yuri Zelikov)
 */
public CustomSavedStateIndicator() {
    this.scheduler = SchedulerInstance.getLowPriorityTimer();
    notifier = new WaveUnsaveNotificator();
    Window.addWindowClosingHandler(new ClosingHandler() {
        @Override
        public void onWindowClosing(final ClosingEvent event) {
            if (currentSavedState != null && currentSavedState.equals(SavedState.UNSAVED)) {
                event.setMessage(I18n.t("WARNING: This document is not saved. "
                        + "Are you sure that you want to navigate away from this page? "
                        + "We advise you to copy the contents you wrote just in case they get lost."));
            }
        }
    });
    // FIXME: http://code.google.com/p/google-web-toolkit/issues/detail?id=5657
    // When history.newItem can be canceled add a similar code to onWindowClosing
}

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

License:Open Source License

/** {@inheritDoc} */
@Override/* w w  w.  j av  a  2s.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:ch.heftix.mailxel.client.MailxelPanel.java

License:Open Source License

public MailxelPanel(final MailServiceAsync mailxelService) {

    super(Unit.EM);

    Window.addWindowClosingHandler(new Window.ClosingHandler() {

        public void onWindowClosing(ClosingEvent event) {
            // check for edit-in-progress
            if (hasEditTab()) {
                event.setMessage("mailxel: do you want to discard unsaved edits? All data will be lost.");
            }/*from   www .  j  av  a 2 s. c o  m*/
        }
    });

    final StatusItem si = statusStart("reading configuration");

    mailxelService.getConfig(new AsyncCallback<ConfigTO>() {

        public void onFailure(Throwable caught) {
            si.error(caught);
            // start welcome wizard
            WelcomeToMailxelPanel wp = new WelcomeToMailxelPanel(mailxelService, MailxelPanel.this);
            addTab(wp, "Welcome");
        }

        public void onSuccess(ConfigTO result) {
            si.done(10000);
            configTO = result;
            if (null == configTO.accountNames || configTO.accountNames.length < 1) {
                WelcomeToMailxelPanel wp = new WelcomeToMailxelPanel(mailxelService, MailxelPanel.this);
                addTab(wp, "Welcome");
            }
        }

    });

    toolBar = new MailxelMainToolBar(mailxelService, this);
    addNorth(toolBar, 3);
    toolBar.add(statusBar);
    // addSouth(statusBar, 3);
    // RootLayoutPanel.get().add(tabLPanel);
    add(tabPanel);
    // add(tabLPanel);

    Panel p = new MailOverviewGrid(mailxelService, this);
    tabPanel.add(p, "Search");
    tabPanel.selectTab(0);

    if (null != configTO && configTO.downloadMailDelay > 0) {
        startDownloadTimer(configTO.downloadMailDelay);
    }

}

From source file:com.calclab.emite.browser.AutoConfigBoot.java

License:Open Source License

@Inject
protected AutoConfigBoot(final XmppConnection connection, final XmppSession session) {
    this.connection = checkNotNull(connection);
    this.session = checkNotNull(session);

    Scheduler.get().scheduleDeferred(this);
    Window.addWindowClosingHandler(this);
}

From source file:com.ephesoft.dcma.gwt.rv.client.ReviewValidate.java

License:Open Source License

@Override
public void onLoad() {
    defineBridgeMethod();/*from   w w w  .  jav  a2  s  .c  o m*/
    Document.get().setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.RV_TITLE));
    final ReviewValidateController controller = new ReviewValidateController(rpcService, eventBus);

    ReviewValidateView view = controller.getPresenter().getView();

    final RootPanel rootPanel = new RootPanel(view.getOuter(), rpcService);
    rootPanel.getHeader().setEventBus(eventBus);
    rootPanel.getHeader().setShowDialogBoxOnTabClick(true);
    rootPanel.getHeader().setDialogMessage(
            LocaleDictionary.get().getMessageValue(ReviewValidateMessages.MSG_BACKBUTTON_CONFM));
    rootPanel.getHeader().addTab(
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TAB_LABEL_HOME), "BatchList.html",
            true);
    rootPanel.getHeader().addNonClickableTab(
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TAB_LABEL_BATCH_DETAIL),
            "ReviewValidate.html");
    rootPanel.getHeader().addTab(
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TAB_LABEL_WEB_SCANNER),
            "WebScanner.html", true);

    checkAndDisplayUploadBatchTab(rootPanel);

    ScreenMaskUtility.maskScreen();

    rpcService.getRowsCount(new EphesoftAsyncCallback<Integer>() {

        public void customFailure(Throwable caught) {
            // no change needed if there is a failure in getting row count
        }

        public void onSuccess(Integer result) {
            if (result == null || result.intValue() == 0) {
                rootPanel.getHeader().getTabBar().setTabEnabled(1, false);
            }
        }
    });

    rpcService.getUserName(new EphesoftAsyncCallback<String>() {

        @Override
        public void onSuccess(String userName) {
            rootPanel.getHeader().setUserName(userName);
            ScreenMaskUtility.unmaskScreen();
        }

        @Override
        public void customFailure(Throwable arg0) {
            ScreenMaskUtility.unmaskScreen();
            ConfirmationDialogUtil.showConfirmationDialogError(
                    LocaleDictionary.get().getMessageValue(ReviewValidateMessages.MSG_USERNAME_ERROR));
        }
    });

    RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get();
    rootLayoutPanel.clear();
    rootLayoutPanel.add(rootPanel);

    final FocusPanel focusPanel = new FocusPanel();
    focusPanel.add(rootLayoutPanel);

    addFocusPanelHandlers(focusPanel);

    com.google.gwt.user.client.ui.RootPanel.get().add(focusPanel);

    Window.addWindowClosingHandler(new Window.ClosingHandler() {

        @Override
        public void onWindowClosing(ClosingEvent arg0) {
            onWindowClose();

        }
    });

    controller.onPresenterLoad(null);

}

From source file:com.ephesoft.gxt.rv.client.layout.ReviewValidateLayout.java

License:Open Source License

private void addWindowClosingHandler() {
    Window.addWindowClosingHandler(new ClosingHandler() {

        @Override//from  w  w w  .j a va 2 s .c  o  m
        public void onWindowClosing(final ClosingEvent event) {
            final String batchInstanceIdentifier = ReviewValidateNavigator.getCurrentBatchInstanceIdentifier();
            if (!StringUtil.isNullOrEmpty(batchInstanceIdentifier)) {
                onWindowClose();
            }
        }
    });
}

From source file:com.fullmetalgalaxy.client.AppMain.java

License:Open Source License

/**
 * /*  w w  w .j ava 2  s  .c om*/
 */
public AppMain() {
    super();
    s_instance = this;
    loadAccountInfoFromPage();

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.takeOff32()));
    hPanel.add(new Label(MAppBoard.s_messages.unconnected()));
    m_pnlChannelDisconnected = new FocusPanel(hPanel);

    // disconnect if leaving this page
    Window.addWindowClosingHandler(this);
}

From source file:com.github.manishahluwalia.gwt.remote_log_handler.client.RemoteLogHandler.java

License:Apache License

public void initialize(String clientLoggingLevel) {
    Window.addWindowClosingHandler(new ClosingHandler() {
        //@Override
        public void onWindowClosing(ClosingEvent e) {
            terminating = true;//from w  w  w  .  j av  a2s. c o m
            flushLogs();
        }
    });

    if (null == clientLoggingLevel) {
        return;
    }

    try {
        Level paramLevel = Level.parse(clientLoggingLevel);
        if (null != paramLevel) {
            wireLogger.fine("Setting client com.github.manishahluwalia.gwt.remote_log_handler level to "
                    + clientLoggingLevel + ", translated to " + paramLevel);
            setLevel(Level.ALL); // set the parent remote log handler to not throttle us, we do our own throttling
            Logger.getGlobal().setLevel(paramLevel);
            Logger.getLogger("").setLevel(paramLevel);
        } else {
            wireLogger.warning("Null parsed param level for clientLogging: " + clientLoggingLevel);
        }
    } catch (Exception e) {
        wireLogger.log(Level.SEVERE,
                "Setting client com.github.manishahluwalia.gwt.remote_log_handler failed for string: "
                        + clientLoggingLevel,
                e);
    }
}