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

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

Introduction

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

Prototype

public synchronized void scheduleRepeating(final int periodMs) 

Source Link

Document

Schedules a timer that elapses repeatedly.

Usage

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

private void loadStockWatcher() {

    // Set up sign out hyperlink.
    signOutLink.setHref(loginInfo.getLogoutUrl());
    // 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.getRowFormatter().addStyleName(0, "watchListHeader");
    stocksFlexTable.addStyleName("watchList"); // moved this here
    stocksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");

    loadStocks();/*from w  ww  .  j a  va 2 s  . com*/

    stocksFlexTable.setCellPadding(6); // this was up top, and was (5)

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

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

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

    // 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() {
        public void onClick(ClickEvent event) {
            addStock();
        }
    });
    // Listen for keyboard events in the input box.
    newSymbolTextBox.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addStock();
            }
        }
    });
}

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

private void setupAnchors() {
    ///* www . ja v  a 2s. c o  m*/
    Date today = new Date();
    DateTimeFormat dateFormat = DateTimeFormat.getFormat("d MMMM yyyy h:mm:ss a (zzzzz)");
    DateTimeFormat yearFormat = DateTimeFormat.getFormat("yyyy");
    //
    copyrightAnchor
            .setHTML("Created by Titus Ong and Yap Yee King, Copyright © " + yearFormat.format(today));
    copyrightAnchor.addStyleName("footer-text");

    //
    dateAnchor.setText(dateFormat.format(today));
    dateAnchor.addStyleName("footer-text");

    Timer t = new Timer() {
        @Override
        public void run() {
            Date todayzzzz = new Date();
            DateTimeFormat dateFormat = DateTimeFormat.getFormat("MMMM d, yyyy h:mm:ss a (zzzzz)");
            dateAnchor.setText(dateFormat.format(todayzzzz));
        }
    };

    t.scheduleRepeating(1000);
}

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

/**
 * Entry point method.//from  www  .  j  a  v  a2 s .  c o m
 */
public void onModuleLoad() {

    // Set the Window title, the header text, and the Add button text.
    Window.setTitle(constants.stockWatcher());
    RootPanel.get("appTitle").add(new Label(constants.stockWatcher()));
    addStockButton = new Button(constants.add());

    // TODO Create table for stock data.
    stocksFlexTable.setText(0, 0, constants.symbol());
    stocksFlexTable.setText(0, 1, constants.price());
    stocksFlexTable.setText(0, 2, constants.change());
    stocksFlexTable.setText(0, 3, constants.remove());

    // 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, "watchListNumbericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumbericColumn");
    stocksFlexTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");

    // TODO Assemble Add Stock panel.
    this.addPanel.add(newSymbolTextBox);
    this.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);

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

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

    });

    //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);

}

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

/**
 ** ENTRY POINT/*from   ww  w.j  a  v  a 2  s .c om*/
 **/

public void onModuleLoad() {
    // TODO Create table for stock data.

    stockTable.setText(0, 0, "Symbol");
    stockTable.setText(0, 1, "Price");
    stockTable.setText(0, 2, "Change");
    stockTable.setText(0, 3, "remove");
    stockTable.setCellPadding(6);

    stockTable.getRowFormatter().addStyleName(0, "watchListHeader");
    stockTable.addStyleName("watchList");
    stockTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
    stockTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
    stockTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");

    // TODO Assemble Add Stock panel.

    addPanel.add(newSymbolBox);
    addPanel.add(addStockButton);
    addPanel.addStyleName("addPanel");

    // TODO Assemble Main panel.

    mainPanel.add(stockTable);
    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.

    newSymbolBox.setFocus(true);

    // TODO Set up timer to automatically refresh list
    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() {
        public void onClick(ClickEvent event) {
            addStock();
        }
    });
    newSymbolBox.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addStock();
            }
        }
    });

}

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

/**
 * Entry point method.//from  w  w w  .j  a va  2  s  .c o m
 */
public void onModuleLoad() {

    //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");

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

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

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

    //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() {
        public void onClick(ClickEvent event) {
            addStock();
        }
    });

    // Listen for keyboard events in the input box.
    newSymbolTextBox.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addStock();
            }
        }
    });

}

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

/**
 * Entry point method./*w  ww .  jav  a  2 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");
    // Assemble Add Stock panel.
    addPanel.add(newSymbolTextBox);
    addPanel.add(addStockButton);

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

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

    // 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);

    addStockButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            addStocks();

        }

    });

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

}

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

public void onModuleLoad() {
    ////from  www.  j a v  a 2  s.  com
    // TODO Create table for stock data. 
    // TODO Assemble Add Stock panel.
    // TODO Assemble Main panel. 
    // TODO Associate the Main panel with the HTML host page. 
    // TODO Move cursor focus to the input box.
    //
    // 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.setCellPadding(6);
    //
    // Add styles to elements in the stock list table.
    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");
    //Assemble Add Stock panel.
    addPanel.add(newSymbolTextBox);
    addPanel.add(addStockButton);
    //
    addPanel.addStyleName("addPanel");
    // Assemble Main panel.
    mainPanel.add(stocksFlexTable);
    mainPanel.add(addPanel);
    mainPanel.add(lastUpdatedLabel);
    //
    //Associate the Main panel with the HTML host page.
    RootPanel.get("stockList").add(mainPanel);

    //
    //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() {
        public void onClick(ClickEvent event) {
            addStock();
        }
    });

    // Listen for keyboard events in the input box.
    newSymbolTextBox.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addStock();
            }
        }
    });

}

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

/**
 * Entry point method.//from ww w. j a va2  s  . c  om
 */
public void onModuleLoad() {
    // 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");

    // 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");

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

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

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

    // 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() {
        public void onClick(ClickEvent event) {
            addStock();
        }
    });

    // Listen for keyboard events in the input box.
    newSymbolTextBox.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addStock();
            }
        }
    });

}

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

/**
 * Entry point method.//from  w ww  .  j  a  v  a2 s. c  o m
 */
public void onModuleLoad() {
    //Create table for stock data.
    //      temperatureFlextable.addTableListener(new TableListener(){
    //
    //         @Override
    //         @Deprecated
    //         public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
    //            setCurrentPlace(temperatureFlextable.getText(row, 0),temperatureFlextable.getText(row, 1), temperatureFlextable.getText(row, 2));
    //            dragController.dragStart();
    //            System.out.println("in the on cell clicked");
    //         }
    //         
    //      });
    temperatureFlextable.setText(0, 0, "Country");
    temperatureFlextable.setText(0, 1, "Area");
    temperatureFlextable.setText(0, 2, "City");
    temperatureFlextable.setText(0, 3, "Temp");
    temperatureFlextable.setText(0, 4, "Change");
    temperatureFlextable.setText(0, 5, "Remove");
    temperatureFlextable.setCellPadding(6);
    // Add styles to elements in the stock list table.
    temperatureFlextable.getRowFormatter().addStyleName(0, "watchListHeader");
    temperatureFlextable.addStyleName("watchList");
    //       stocksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
    //       stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
    temperatureFlextable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");
    temperatureFlextable.getCellFormatter().addStyleName(0, 4, "watchListRemoveColumn");
    newSymbolTextBox.setTitle("Country");
    newAreaTextBox.setTitle("Region");
    newCityTextBox.setTitle("City");
    addPanel.add(newSymbolTextBox);
    addPanel.add(newAreaTextBox);
    addPanel.add(newCityTextBox);

    addPanel.add(addCityButton);
    addPanel.addStyleName("addPanel");
    errorMsgLabel.setStyleName("errorMessage");
    errorMsgLabel.setVisible(false);

    //part 2
    //Create table for stock data.
    temperatureFlextable2.setText(0, 0, "Country");
    temperatureFlextable2.setText(0, 1, "Area");
    temperatureFlextable2.setText(0, 2, "City");
    temperatureFlextable2.setText(0, 3, "Temp");
    temperatureFlextable2.setText(0, 4, "Change");
    temperatureFlextable2.setText(0, 5, "Remove");
    temperatureFlextable2.setCellPadding(6);
    // Add styles to elements in the stock list table.
    temperatureFlextable2.getRowFormatter().addStyleName(0, "watchListHeader");
    temperatureFlextable2.addStyleName("watchList");
    //       stocksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
    //       stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
    temperatureFlextable2.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");
    temperatureFlextable2.getCellFormatter().addStyleName(0, 4, "watchListRemoveColumn");
    PickupDragController dragController2 = new PickupDragController(RootPanel.get(), true);
    dragController2.makeDraggable(temperatureFlextable);

    //      //DRAG AND DROP
    //      RootPanel.get().setPixelSize(1000,1000);
    //      PickupDragController dragController = new PickupDragController(RootPanel.get(),true);
    //      Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    //      RootPanel.get().add(img,40,30);
    //      dragController.makeDraggable(img);
    //      //

    mainPanel.add(errorMsgLabel);
    // Assemble Main panel.
    mainPanel.add(temperatureFlextable);
    //      mainPanel.add(labelPanel);
    mainPanel.add(addPanel);
    mainPanel.add(temperatureFlextable2);
    mainPanel.add(lastUpdatedLabel);

    // Associate the Main panel with the HTML host page.
    RootPanel.get("stockList").add(mainPanel);
    // 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.
    addCityButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            addCity();
        }
    });
    // Listen for keyboard events in the input box.
    newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
                addCity();
            }
        }
    });
    newCityTextBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
                addCity();
            }
        }
    });
    newAreaTextBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
                addCity();
            }
        }
    });

    dragController.setBehaviorDragProxy(true);
    dragController.registerDropController(dropController);
}

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

public StockWatcherViewImpl() {
    initFlexTable();//from  w  w w . j a v  a  2 s .c  o  m

    // Setup timer to refresh list automatically.
    Timer refreshTimer = new Timer() {
        @Override
        public void run() {
            refreshWatchList();
        }
    };
    refreshTimer.scheduleRepeating(REFRESH_INTERVAL);
    initWidget(uiBinder.createAndBindUi(this));

    aboutMenuItem.setCommand(new Command() {

        @Override
        public void execute() {
            Window.alert("fuck...");
        }
    });
}