List of usage examples for com.google.gwt.user.client Timer Timer
Timer
From source file:com.google.gwt.sample.stockwatcher.client.ui.StockWatcherViewImpl.java
public StockWatcherViewImpl() { initFlexTable();/*from w w w. j av a 2 s.c om*/ // 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..."); } }); }
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();/* w w w . j a v a 2s . co 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);//from w w w .j a v a2s. com 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. ja v a 2 s . c o 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 .jav a2s .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./*from www. j a va 2 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.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 va 2 s .c om // 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 a v a2 s . c om // 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.livingstories.client.lsp.views.contentitems.LocationView.java
License:Apache License
public LocationView(Location location) { this.location = location; initWidget(uiBinder.createAndBindUi(this)); AjaxLoaderOptions options = AjaxLoaderOptions.newInstance(); options.setOtherParms(LivingStoryData.getMapsKey() + "&sensor=false"); // Instantiating the map via a runnable breaks horribly on firefox, for reasons // that are still mysterious to us. If we introduce some delay, though, // it works fine, and doesn't greatly hurt overall page functionality. AjaxLoader.loadApi("maps", "2", new Runnable() { @Override//from w ww . j a va 2 s .c o m public void run() { new Timer() { @Override public void run() { content.add(createMap()); } }.schedule(1000); } }, options); }
From source file:com.google.livingstories.client.ui.GlassPanel.java
License:Apache License
public GlassPanel() { glass = new SimplePanel(); glass.setStylePrimaryName("fixedGlass"); Element element = glass.getElement(); DOM.setStyleAttribute(element, "backgroundColor", "#000000"); DOM.setStyleAttribute(element, "opacity", "0.50"); DOM.setStyleAttribute(element, "MozOpacity", "0.50"); DOM.setStyleAttribute(element, "filter", "alpha(opacity=50)"); glass.setVisible(false);//from w w w. j a v a 2 s .c o m initWidget(glass); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { if (isVisible()) { sizeToDocument(); if (timer != null) { timer.cancel(); } // We need to call sizeToDocument() a second time, asynchronously, to get inappropriate // scrollbars to disappear when making the window smaller. We do this with a small // timeout, though, so as not to repeatedly call extra sizeToDocument over // the course of a drag. timer = new Timer() { @Override public void run() { // the size actually has to change to get the layout to reflow... glass.setSize("1px", "1px"); sizeToDocument(); timer = null; } }; timer.schedule(100); } } }); }