List of usage examples for com.google.gwt.user.client Timer scheduleRepeating
public synchronized void scheduleRepeating(final int periodMs)
From source file:com.google.gwt.sample.stockwatcher.StockWatcher.client.StockWatcher.java
License:Open Source License
public void onModuleLoad() { // setup timer to refresh list automatically Timer refreshTimer = new Timer() { public void run() { refreshWatchList();//from w w w. ja v a 2 s .c o m } }; refreshTimer.scheduleRepeating(REFRESH_INTERVAL); RootPanel rootPanel = RootPanel.get(); rootPanel.setStyleName("gwt-Label-StockWatcher"); VerticalPanel mainPanel = new VerticalPanel(); rootPanel.add(mainPanel, 10, 147); mainPanel.setSize("311px", "167px"); stocksFlexTable = new FlexTable(); //Aadir valores a la tabla stocksFlexTable.setText(0, 0, "Symbol"); stocksFlexTable.setText(0, 1, "Price"); stocksFlexTable.setText(0, 2, "Change"); stocksFlexTable.setText(0, 3, "Remove"); mainPanel.add(stocksFlexTable); addPanel = new HorizontalPanel(); mainPanel.add(addPanel); addPanel.setSize("272px", "56px"); newSymbolTextBox = new TextBox(); newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { addStock(); } } }); newSymbolTextBox.setFocus(true); addPanel.add(newSymbolTextBox); addButton = new Button("Add"); addButton.setStyleName("gwt-Button-Add"); addButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { addStock(); } }); addPanel.add(addButton); lastUpdatedLabel = new Label("New label"); mainPanel.add(lastUpdatedLabel); image = new Image("images/googlecode.png"); rootPanel.add(image, 10, 10); image.setSize("221px", "84px"); lblNewLabel = new Label("Stock Watcher"); rootPanel.add(lblNewLabel, 20, 100); lblNewLabel.setSize("186px", "16px"); }
From source file:com.google.gwt.sample.stockwatcher.uibinder.client.StockWatcherWidget.java
private void initUI() { stockFlexTable.setText(0, 0, "Symbol"); stockFlexTable.setText(0, 1, "Price"); stockFlexTable.setText(0, 2, "Change"); stockFlexTable.setText(0, 3, "Remove"); // Add styles stockFlexTable.setCellPadding(6);/* w w w .ja va2 s. c o m*/ stockFlexTable.getRowFormatter().addStyleName(0, "watchListHeader"); stockFlexTable.addStyleName("watchList"); stockFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn"); stockFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn"); stockFlexTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn"); 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.stockwatcher2.StockWatcher2.client.StockWatcher2.java
/** * This is the entry point method.//w w w . jav a 2s .co m */ public void onModuleLoad() { // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel rootPanel = RootPanel.get("stockList"); rootPanel.setStyleName("rootPanel"); mainPanel = new VerticalPanel(); rootPanel.add(mainPanel, 10, 0); mainPanel.setSize("304px", "224px"); Image image = new Image("images/GoogleCode.png"); mainPanel.add(image); Label labelStockWatcher = new Label("Stock Watcher"); labelStockWatcher.setStyleName("gwt-Label-StockWatcher"); mainPanel.add(labelStockWatcher); stocksflexTable = new FlexTable(); stocksflexTable.getRowFormatter().addStyleName(0, "watchListHeader"); stocksflexTable.setCellPadding(6); stocksflexTable.setStyleName("watchList"); stocksflexTable.getCellFormatter().addStyleName(0, 1, "watchListN"); stocksflexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn"); stocksflexTable.setText(0, 0, "Symbol"); stocksflexTable.setText(0, 1, "Price"); stocksflexTable.setText(0, 2, "Change"); stocksflexTable.setText(0, 3, "Remove"); mainPanel.add(stocksflexTable); stocksflexTable.setWidth("222px"); addPanel = new HorizontalPanel(); mainPanel.add(addPanel); newSymbolTextBox = new TextBox(); newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { addStock(); } } }); addPanel.add(newSymbolTextBox); addButton = new Button("New button"); addButton.setStyleName("gwt-Button-Add"); addButton.setHeight("25px"); addButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { addStock(); } }); addButton.setText("Add"); addPanel.add(addButton); lastUpdateLabel = new Label("New label"); mainPanel.add(lastUpdateLabel); // setup timer to refresh list automatically Timer refreshTimer = new Timer() { public void run() { refreshWatchList(); } }; refreshTimer.scheduleRepeating(REFRESH_INTERVAL); }
From source file:com.google.gwt.sample.stockwatcher_json.client.StockWatcherJSON.java
/** * Entry point method.//w w w. ja va 2s . c o m */ public void onModuleLoad() { stocksFlexTable.setText(0, 0, "Symbol"); stocksFlexTable.setText(0, 1, "Price"); stocksFlexTable.setText(0, 2, "Change"); stocksFlexTable.setText(0, 3, "Remove"); stocksFlexTable.setCellPadding(6); stocksFlexTable.getRowFormatter().addStyleName(0, "watchListHeader"); stocksFlexTable.addStyleName("watchList"); stocksFlexTable.getColumnFormatter().addStyleName(1, "watchListNumericColumn"); stocksFlexTable.getColumnFormatter().addStyleName(2, "watchListNumericColumn"); stocksFlexTable.getColumnFormatter().addStyleName(3, "watchListRemoveColumn"); addPanel.add(newSymbolTextBox); addPanel.add(addStockButton); addPanel.add(randomizeButton); addPanel.setStyleName("addPanel"); errorMsgLabel.setStyleName("errorMessage"); errorMsgLabel.setVisible(false); randomizeLabel.setVisible(false); mainPanel.add(errorMsgLabel); mainPanel.add(stocksFlexTable); mainPanel.add(addPanel); mainPanel.add(lastUpdatedLabel); mainPanel.add(new HTML("<br/>")); mainPanel.add(randomizeLabel); RootPanel.get("stockList").add(mainPanel); newSymbolTextBox.setFocus(true); // Listen for mouse events on the Add button. addStockButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { addStock(); } }); randomizeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { randomizeNumber(); } }); // Listen for keyboard events in the input box. newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { addStock(); } } }); // Setup timer to refresh list automatically. Timer refreshTimer = new Timer() { @Override public void run() { if (!stocks.isEmpty()) { refreshWatchList(); } } }; refreshTimer.scheduleRepeating(REFRESH_INTERVAL); }
From source file:com.google.gwt.sample.stockwatcher_rpc.client.StockWatcherRPC.java
/** * Entry point method.// w ww. j a v a 2s . 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.add(randomizeButton); addPanel.addStyleName("addPanel"); // Assemble Main panel. errorMsgLabel.setStyleName("errorMessage"); errorMsgLabel.setVisible(false); randomizeLabel.setVisible(false); mainPanel.add(errorMsgLabel); mainPanel.add(stocksFlexTable); mainPanel.add(addPanel); mainPanel.add(lastUpdatedLabel); mainPanel.add(new HTML("<br/>")); mainPanel.add(randomizeLabel); // 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() { if (!stocks.isEmpty()) { refreshWatchList(); } } }; refreshTimer.scheduleRepeating(REFRESH_INTERVAL); // Listen for mouse events on the Add button. addStockButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { addStock(); } }); randomizeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { randomizeNumber(); } }); // Listen for keyboard events in the input box. newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { addStock(); } } }); }
From source file:com.google.gwt.sample.userwatcher.client.PageWithoutPhoto.java
public PageWithoutPhoto() { // 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);/*from w ww . j a va2s . com*/ // 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"); errorMsgLabel.setStyleName("errorMessage"); errorMsgLabel.setVisible(false); mainPanel.add(errorMsgLabel); // Assemble Main panel. mainPanel.add(stocksFlexTable); mainPanel.add(addPanel); mainPanel.add(lastUpdatedLabel); // 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(); } } }); initWidget(mainPanel); }
From source file:com.google.gwt.sample.userwatcher.client.PageWithPhoto.java
public PageWithPhoto() { // 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);/*from ww w.j av a 2 s . co m*/ // 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"); ClientPersistence cp = new ClientPersistence(); FileUploaderWidget_v2 fuw = new FileUploaderWidget_v2(cp); // Assemble Add Stock panel. addPanel.add(newSymbolTextBox); addPanel.add(addStockButton); addPanel.addStyleName("addPanel"); addPanel.add(fuw); fuw.draw(); fuw.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { FileUploaderWidget_v2 f = (FileUploaderWidget_v2) event.getSource(); int e = f.getChangeEvent(); processChange(e); } }); errorMsgLabel.setStyleName("errorMessage"); errorMsgLabel.setVisible(false); mainPanel.add(errorMsgLabel); // Assemble Main panel. mainPanel.add(stocksFlexTable); mainPanel.add(addPanel); mainPanel.add(lastUpdatedLabel); // 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(); } } }); initWidget(mainPanel); }
From source file:com.google.mobile.trippy.web.client.Trippy.java
License:Apache License
private void init() { eventBus = singletonComponent.getEventBus(); tripService = singletonComponent.getTripService(); toast = singletonComponent.getToast(); utils = singletonComponent.getUtils(); messages = singletonComponent.getMessage(); // Expose methods to android shell app. AndroidProxy proxy = new AndroidProxy(eventBus); proxy.setDoSearch(proxy);//from w w w . j a va 2s . c o m final String cls = Window.Location.getParameter("cls"); if (cls != null && cls.toLowerCase().equals("true")) { LocalDbService.clearDb(); } initDb(); utils.addOnlineHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(final ValueChangeEvent<Boolean> event) { if (event.getValue()) { toast.showToast(messages.onLineStatusMsg()); } else { toast.showToast(messages.offLineStatusMsg()); } } }); utils.startCheckOnlineTimer(); // utils.startLocationUpdateTimer(); toast.showLoading(messages.loading()); syncFromRemoteDb(new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { toast.hideLoading(); } @Override public void onFailure(Throwable caught) { toast.hideLoading(); } }); final Timer timer = new Timer() { @Override public void run() { syncFromRemoteDb(); } }; // Sync db after every 60 secs. timer.scheduleRepeating(SYNC_PERIOD); }
From source file:com.googlecode.gwtgl.example.client.AbstractGwtGLExample.java
License:Apache License
/** * Starts the execution of the example. First the example is initialized * using {@link AbstractGwtGLExample#init()}. After that the rendering loop * is executed with 50 fps. Each frame is rendered using * {@link AbstractGwtGLExample#draw()}.//w ww . j a v a 2 s . c o m */ private void start() { init(); Timer timer = new Timer() { @Override public void run() { draw(); } }; timer.scheduleRepeating(20); }
From source file:com.googlecode.gwtgl.example.client.examples.lighting.wrapper.LightingWrapperExample.java
License:Apache License
/** * Updates the Matrix widgets every 500ms *///w ww . j a v a 2 s .c o m private void showMatrices() { Timer timer = new Timer() { @Override public void run() { perspectiveMatrixWidget.setData(perspectiveMatrix); translationMatrixWidget.setData(translationMatrix); rotationMatrixWidget.setData(rotationMatrix); resultingMatrixWidget.setData(resultingMatrix); } }; timer.scheduleRepeating(500); }