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

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

Introduction

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

Prototype

Timer

Source Link

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.AnimateDemo.java

License:Apache License

@Override
public void onShow() {
    map.setCenter(start);// ww w . j av  a2  s .  c  o  m
    new Timer() {
        @Override
        public void run() {
            map.panTo(end);
        }
    }.schedule(1000);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.ControlsDemo.java

License:Apache License

public ControlsDemo() {
    map = new MapWidget(LatLng.newInstance(37.4419, -122.1419), 13);
    map.setSize("500px", "300px");
    initWidget(map);//from   w w  w. j  a v a 2s .  c o m
    map.addControl(new SmallMapControl());
    map.addControl(new MapTypeControl());

    Timer timer = new Timer() {

        @Override
        public void run() {
            // Exercise the minimum & maximum resolution entry points.
            MapType types[] = map.getMapTypes();
            for (MapType t : types) {
                int minResolution = t.getMinimumResolution();
                int maxResolution = t.getMaximumResolution();
                GWT.log("Map Type: " + t.getName(true) + " Min resolution: " + minResolution
                        + " Max Resolution: " + maxResolution, null);

                minResolution = t.getMinimumResolution();
                maxResolution = t.getMaximumResolution();
                GWT.log("@ point: " + map.getCenter().toString() + " Map Type: " + t.getName(true)
                        + " Min resolution: " + minResolution + " Max Resolution: " + maxResolution, null);
            }
        }
    };
    timer.schedule(1000);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.CustomControlDemo.java

License:Apache License

public CustomControlDemo() {

    VerticalPanel vertPanel = new VerticalPanel();
    vertPanel.setStyleName("hm-panel");

    actionListBox = new ListBox();
    for (ControlDemos cd : ControlDemos.values()) {
        actionListBox.addItem(cd.valueOf());
    }/* w ww.  j av a 2s . c o m*/

    actionListBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            displayCustomControl();
        }
    });

    HorizontalPanel horizPanel = new HorizontalPanel();
    horizPanel.add(new Label("Choose Action:"));
    horizPanel.add(actionListBox);
    horizPanel.setSpacing(10);
    vertPanel.add(horizPanel);

    map = new MapWidget(LatLng.newInstance(37.441944, -122.141944), 13);
    map.setSize("500px", "300px");
    map.addMapType(MapType.getNormalMap());
    map.addMapType(MapType.getSatelliteMap());
    map.addMapType(MapType.getMarsVisibleMap());
    map.addMapType(MapType.getMarsElevationMap());
    map.addMapType(MapType.getMarsInfraredMap());
    vertPanel.add(map);

    new Timer() {
        public void run() {
            displayCustomControl();
        }
    }.schedule(250);

    initWidget(vertPanel);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.EarthPluginDemo.java

License:Apache License

public EarthPluginDemo() {
    Panel panel = new FlowPanel();
    map = new MapWidget(LatLng.newInstance(37.42317, -122.08364), 16);
    map.setSize("500px", "500px");
    map.addControl(new SmallMapControl());
    map.addMapType(MapType.getEarthMap());
    map.setCurrentMapType(MapType.getEarthMap());
    panel.add(map);/*from  w  ww. j a va 2 s  .  c o m*/
    initWidget(panel);
    map.getEarthInstance(new EarthInstanceHandler() {

        public void onEarthInstance(EarthInstanceEvent event) {
            final JavaScriptObject earth = event.getEarthInstance();
            if (earth == null) {
                Window.alert("Failed to init earth plugin");
            } else {
                /*
                 * Create a marker. The timer is set to give the earth plugin a chance
                 * to position to the proper point on the map.
                 */
                new Timer() {

                    @Override
                    public void run() {
                        createPlacemark(earth);
                    }
                }.schedule(1000);
            }
        }
    });
}

From source file:com.google.gwt.maps.testing.client.maps.StreetViewSideBySideMapWidget.java

License:Apache License

/**
 * render the components in the widget/*from  w  ww.j a  v  a  2 s.  co  m*/
 */
private void draw() {
    pWidget.clear();

    pWidget.add(new HTML("<br>Street View Demo - click on the map"));

    hp = new HorizontalPanel();
    pWidget.add(hp);

    drawMap();

    drawStreeView();

    // allow for things to setup, otherwise getting pano gets null
    Timer t = new Timer() {
        public void run() {
            setupStartingMarker();
        }
    };
    t.schedule(1500); // b/c this widget is first and I have so many loading on
                      // page.
}

From source file:com.google.gwt.maps.testing.client.maps.TransitDirectionsServiceMapWidget.java

License:Apache License

private void draw() {
    pWidget.clear();//from   w w  w  . j ava  2s .co m
    pWidget.add(new HTML("<br/>"));

    HorizontalPanel hp = new HorizontalPanel();
    pWidget.add(hp);
    hp.add(new HTML("Transit Directions Service&nbsp;&nbsp;&nbsp;&nbsp;"));
    hp.add(htmlStatus);
    drawMap();
    htmlSummary = new HTML();
    pWidget.add(htmlSummary);

    nRequests = 0;
    Timer directionsTimer = new Timer() {
        @Override
        public void run() {
            drawRandomDirections();
            /*
             * We do not want to make the client to be blacklisted by Google if its browser window is left open for too
             * long... :)
             */
            if (nRequests++ > 10)
                cancel();
        }
    };
    directionsTimer.scheduleRepeating(10000);
    drawRandomDirections();
}

From source file:com.google.gwt.sample.client.mystockwatcherEntryPoint.java

/** 
 * The entry point method, called automatically by loading a module
 * that declares an implementing class as an entry-point
 *//*from w w  w  . j  a  v a2 s . c  o m*/
public void onModuleLoad() {
    // TODO Create table for stock data.
    stocksFlexTable.setText(0, 0, "Symbol");
    stocksFlexTable.setText(0, 1, "Price");
    stocksFlexTable.setText(0, 2, "Change");
    stocksFlexTable.setText(0, 3, "Remove");
    //stocksFlexTable.setText(0, 4, JSON_URL);

    // Add styles to elements in the stock list table.
    stocksFlexTable.setCellPadding(6);
    stocksFlexTable.getRowFormatter().addStyleName(0, "watchListHeader");
    stocksFlexTable.addStyleName("watchList");
    stocksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");

    // TODO Assemble Add Stock panel.
    addPanel.add(newSymbolTextBox);
    addPanel.add(addStockButton);
    addPanel.addStyleName("addPanel");

    // TODO Assemble Main panel.
    errorMsgLabel.setStyleName("errorMessage");
    errorMsgLabel.setVisible(false);

    mainPanel.add(errorMsgLabel);
    mainPanel.add(stocksFlexTable);
    mainPanel.add(addPanel);
    mainPanel.add(lastUpdatedLabel);

    // TODO Associate the Main panel with the HTML host page.
    RootPanel.get("stockList").add(mainPanel);

    // TODO Move cursor focus to the input box.
    newSymbolTextBox.setFocus(true);

    // Setup timer to refresh list automatically.
    Timer refreshTimer = new Timer() {

        @Override
        public void run() {
            refreshWatchList();
        }
    };
    refreshTimer.scheduleRepeating(REFRESH_INTERVAL);

    // Listen for mouse events on the Add button.
    addStockButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            addStock();
        }
    });

    // Listen for keyboard events in the input box.
    newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
                addStock();
            }
        }
    });

}

From source file:com.google.gwt.sample.client.stockwatcher.java

public void onModuleLoad() {
    //  Create table for stock data
    stocksTable.setText(0, 0, "Symbol");
    stocksTable.setText(0, 1, "Price");
    stocksTable.setText(0, 2, "Change");
    stocksTable.setText(0, 3, "Remove");

    // Add styles to elements in the stock list table.
    stocksTable.setCellPadding(6);//from   w w  w.ja  v  a  2  s.  co m
    stocksTable.getRowFormatter().addStyleName(0, "watchListHeader");
    stocksTable.addStyleName("watchList");
    stocksTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
    stocksTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
    stocksTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");

    //   Assemble Add Stock panel
    addPanel.add(textBox);
    addPanel.add(addButton);
    addPanel.addStyleName("addPanel");

    // Assemble Main panel
    mainPanel.add(stocksTable);
    mainPanel.add(addPanel);
    mainPanel.add(lastUpdatedLabel);

    // Associate the Main panel with the HTML host page.
    RootPanel.get("div_GWTRoot").add(mainPanel);

    // Move cursor focus to the input box.
    addButton.setFocus(true);

    //   Setup timer to refresh list automatically
    timer = new Timer() {
        @Override
        public void run() {
            refreshWatchList();
        }
    };
    timer.scheduleRepeating(INTERVAL);

    // Listen for mouse events on the Add button.
    addButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            addStock();
        }
    });

    // Listen for keyboard events in the input box.
    textBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                addStock();
            }
        }
    });

}

From source file:com.google.gwt.sample.compraventa.client.Compraventa.java

public void onModuleLoad() {

    ofertasFlexTable.setText(0, 0, "Oferta Compra");
    ofertasFlexTable.setText(0, 1, "Oferta Venta");

    System.out.println("Estoy adentro del onModuleLoad");

    //       GWT.log("estoy en el onModuleLoad");

    agregarPanel.add(cuotaTextBox);//from w  w w . j a v a  2  s. co m
    agregarPanel.add(montoTextBox);
    agregarPanel.add(comprarRadioButton);
    agregarPanel.add(venderRadioButton);
    agregarPanel.add(agregarButton);
    agregarPanel.add(actualizarButton);

    // Assemble Main panel.

    mainPanel.add(agregarPanel);
    mainPanel.add(lastUpdatedLabel);
    mainPanel.add(ofertasFlexTable);

    RootPanel.get("ofertasList").add(mainPanel);

    agregarButton.setFocus(true);
    comprarRadioButton.setEnabled(true);

    // Escuchamos por el evento de agregar
    agregarButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            agregarOferta();
            actualizarDatos();
        }
    });

    actualizarButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            actualizarDatos();
        }
    });

    montoTextBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
                agregarOferta();
            }
        }
    });

    cargarDatos();
    Timer refreshTimer = new Timer() {
        @Override
        public void run() {
            agregarDatosFantasia();
            actualizarDatos();
        }
    };
    refreshTimer.scheduleRepeating(REFRESH_INTERVAL);
}

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

License:Apache License

/**
 * Initialize the global state of the application.
 *///from  w  ww  .  ja v  a  2 s.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);
}