Example usage for com.google.gwt.user.client WindowCloseListener WindowCloseListener

List of usage examples for com.google.gwt.user.client WindowCloseListener WindowCloseListener

Introduction

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

Prototype

WindowCloseListener

Source Link

Usage

From source file:com.google.gwt.sample.feedreader.client.GwtFeedReader.java

License:Apache License

/**
 * Initialize the global state of the application.
 *///from   w w  w.j av a2s . co m
private void initialize() {
    // This function should only work once.
    if (configuration != null) {
        return;
    }

    configuration = new Configuration();

    // Create the root UI element
    manifest = new ManifestPanel(configuration);

    // Use a WindowCloseListener to save the configuration
    Window.addWindowCloseListener(new WindowCloseListener() {

        public void onWindowClosed() {
            configuration.save();
        }

        public String onWindowClosing() {
            // TODO have a configuration value to warn before closing.
            return null;
        }
    });

    // Start a timer to automatically save the configuration in case of sudden
    // exit.
    (new Timer() {
        public void run() {
            configuration.save();
        }
    }).scheduleRepeating(1000 * 60 * 5);

    // Add a HistoryListener to control the application.
    History.addHistoryListener(new HistoryListener() {
        /**
         * Prevent repeated loads of the same token.
         */
        String lastToken = "";

        public void onHistoryChanged(String token) {
            if (lastToken.equals(token)) {
                return;
            }

            if (token != null) {
                lastToken = token;
                processHistoryToken(token);
            }
        }
    });

    // The stylesheet are factored into two pieces: a common template
    // that defines sizes and structural elements.
    StyleInjector.injectStylesheet(Resources.INSTANCE.layoutCss().getText());
    // And further CSS rules that provide look-and-feel and localized resources
    StyleInjector.injectStylesheet(Resources.INSTANCE.appearanceCss().getText(), Resources.INSTANCE);

    UnsunkLabel logo = new UnsunkLabel();
    logo.addStyleName("logo");
    RootPanel.get().add(logo, 0, 0);
}

From source file:com.italianasoftware.echoes.client.Echoes.java

License:Open Source License

private void startClientSession() {
    Value val = getLocationValue();
    JolieService.Util.getInstance().call("startClientSession", val, new EchoesCallback() {
        @Override//from  w  w w .ja va 2s .  co m
        public void onSuccess(Value response) {
            setWidgetValues(response);
            sid = response.getFirstChild("sid").intValue();
            logicalClock = response.getFirstChild("logicalClock").intValue();

            Window.addWindowCloseListener(new WindowCloseListener() {
                public String onWindowClosing() {
                    return null;
                }

                public void onWindowClosed() {
                    closeClientSession();
                }
            });
        }
    });
}

From source file:com.objetdirect.tatami.client.dnd.DnDMainController.java

License:Open Source License

/**
 * Private default constructor/*from  w ww .ja  v a 2s  .  c  o m*/
 * It adds a WindowListener to clean up the various dnd elements 
 */
private DnDMainController() {
    DojoController.getInstance().require("dojo.dnd.Source");
    jssources = new HashMap<JavaScriptObject, IDnDController<?, ?>>();
    jstargets = new HashMap<JavaScriptObject, IDnDController<?, ?>>();
    controllers = new ArrayList<IDnDController<?, ?>>();
    Window.addWindowCloseListener(new WindowCloseListener() {
        public String onWindowClosing() {
            return null;
        }

        public void onWindowClosed() {
            destroyDnDEngine();
        }
    });
}

From source file:org.jboss.bpm.console.client.search.SearchWindow.java

License:Open Source License

/**
* The 'layout' window panel./*from   w w  w  .  ja va2 s . c  o  m*/
*/
private void createLayoutWindowPanel(String title, SearchDefinitionView view) {
    window = new WindowPanel(title);
    window.setAnimationEnabled(true);
    window.setSize("250px", "160px");

    window.setWidget(view);

    window.addWindowCloseListener(new WindowCloseListener() {
        public void onWindowClosed() {
            window = null;
        }

        public String onWindowClosing() {
            return null;
        }
    });
}

From source file:rocket.beans.client.BeanFactoryImpl.java

License:Apache License

protected void registerShutdownHook() {
    Window.addWindowCloseListener(new WindowCloseListener() {
        public String onWindowClosing() {
            return null;
        }//from  ww  w.  j av a  2  s. c om

        public void onWindowClosed() {
            BeanFactoryImpl.this.shutdown();
        }
    });
}