private void handleError(Throwable error) { Window.alert(error.getMessage()); if (error instanceof NotLoggedInException) { Window.Location.replace(loginInfo.getLogoutUrl()); } }
private void loadStockWatcher() { // Set up sign out hyperlink. signOutLink.setHref(loginInfo.getLogoutUrl()); // Create table for tasks. tasksFlexTable.setText(0, 0, "Tâche"); tasksFlexTable.setText(0, 1, "DeadLine"); tasksFlexTable.setText(0, 2, "Priorité"); tasksFlexTable.setText(0, 3, "Remove"); // Add styles to elements in the stock list table. tasksFlexTable.getRowFormatter().addStyleName(0, "watchListHeader"); tasksFlexTable.addStyleName("watchList"); tasksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn"); tasksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn"); tasksFlexTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn"); loadStocks(); // Assemble Add Task panel. addPanel.add(newTaskTextBox); addPanel.add(addTaskButton); addPanel.addStyleName("addPanel"); // Assemble Main panel. errorMsgLabel.setStyleName("errorMessage"); errorMsgLabel.setVisible(false); mainPanel.add(errorMsgLabel); mainPanel.add(signOutLink); mainPanel.add(tasksFlexTable); mainPanel.add(addPanel); mainPanel.add(lastUpdatedLabel); // Associate the Main panel with the HTML host page. RootPanel.get("tasksList").add(mainPanel); // Move cursor focus to the input box. newTaskTextBox.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. addTaskButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { addTask(); } }); // Listen for keyboard events in the input box. newTaskTextBox.addKeyPressHandler( new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { addTask(); } } }); }