List of usage examples for com.google.gwt.user.client HistoryListener HistoryListener
HistoryListener
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 a 2s.c o 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); }