private GwtCommandDispatcher() { locale = LocaleInfo.getCurrentLocale().getLocaleName(); if ("default".equals(locale)) { locale = null; } deferreds = new ArrayList<Deferred>(); service = (GeomajasServiceAsync) GWT.create(GeomajasService.class); setServiceEndPointUrl(GWT.getModuleBaseURL() + "geomajasService"); setUseLazyLoading(true); setShowError(true); Window.addWindowClosingHandler(new ClosingHandler() { public void onWindowClosing(ClosingEvent event) { GwtCommandDispatcher.getInstance().setShowError(false); // Cancel all outstanding requests: for (Deferred deferred : deferreds) { deferred.cancel(); } } }); }
private void releaseLockOnClose() { closeHandler = Window.addWindowClosingHandler(new ClosingHandler() { @Override public void onWindowClosing(ClosingEvent event) { releaseLock(); } }); }
public static void createMenuCloseEvent(final String uuid, final WindowPanel sender) { sender.addWindowClosingHandler(new ClosingHandler() { public void onWindowClosing(ClosingEvent event) { if (Window.confirm("Are you sure you want to close the application and all of its windows ?")) { MainFactoryActions.remove(uuid); ComponentRepository.getInstance().removeAllItemsForWindow(uuid, null); // ClientApplicationContext.getInstance().closeAllWindowsForUUID(uuid); // return true; } else { // return false; } Window.prompt("Are you sure you want to close the application and all of its windows ?", "X"); } }); }
/** * Set up the History management for the application. */ public void setUpHistoryManagement(){ // Make this class your history manager (see onValueChange method) History.addValueChangeHandler(this); // Handle any existing history token History.fireCurrentHistoryState(); // Trap user hitting back button too many times. Window.addWindowClosingHandler(new ClosingHandler(){ public void onWindowClosing(ClosingEvent event) { event.setMessage("Ran out of history. Now leaving application, is that OK?"); } }); }
/** * Display a confirmation dialog to leave our site when the user refreshes * or goes to another URL. */ protected void initWindowClosingConfirmationDialog() { Window.addWindowClosingHandler(new ClosingHandler() { @Override public void onWindowClosing(ClosingEvent event) { // This message doesn't show, but by adding this close handler, // we get the default dialog to display and confirm that the // user does want to leave our site. event.setMessage("Are you sure you want to leave?"); } }); }