Exemplo n.º 1
0
  private void loadData() {
    // Set up the callback object.
    AsyncCallback<AccountInfo[]> callback =
        new AsyncCallback<AccountInfo[]>() {
          public void onFailure(Throwable caught) {
            // TODO: Do something with errors.
            GWT.log(caught.toString());
            refreshBtn.setEnabled(true);
          }

          public void onSuccess(AccountInfo[] info) {
            if (info == null) {
              Window.alert(MockStock.SESSION_TIMEOUT_MSG);
              return;
            }
            populateRankTable(info);
            refreshBtn.setEnabled(true);

            String time =
                "最后更新时间: "
                    + DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_SHORT)
                        .format(new Date())
                    + " "
                    + DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.TIME_MEDIUM)
                        .format(new Date());
            lastModified.setText(time);
            hp.add(lastModified);
            hp.setCellHorizontalAlignment(lastModified, ALIGN_RIGHT);
            hp.setCellVerticalAlignment(lastModified, ALIGN_BOTTOM);
          }
        };
    // Make the call to the stock price service.
    stockSvc.getAllAccountInfo(callback);
  }
Exemplo n.º 2
0
  private void showTransHistory(final String username, final String displayName) {
    AsyncCallback<DealLog[]> callback =
        new AsyncCallback<DealLog[]>() {
          public void onFailure(Throwable caught) {
            // TODO: Do something with errors.
            GWT.log(caught.toString());
          }

          public void onSuccess(DealLog[] logs) {
            if (logs == null) {
              Window.alert(MockStock.SESSION_TIMEOUT_MSG);
              return;
            }
            removeGrids();
            createTransTable(logs);
            transUser = new Label("\"" + displayName + "\"交易记录如下:");
            getItself().add(transUser);
            getItself().add(transGrid);
          }
        };
    // Make the call to the stock price service.
    stockSvc.getDealLogs(username, callback);
  }
Exemplo n.º 3
0
  private void showPosition(final String username, final String displayName) {
    AsyncCallback<StockPosition[]> callback =
        new AsyncCallback<StockPosition[]>() {
          public void onFailure(Throwable caught) {
            // TODO: Do something with errors.
            GWT.log(caught.toString());
          }

          public void onSuccess(StockPosition[] positions) {
            if (positions == null) {
              Window.alert(MockStock.SESSION_TIMEOUT_MSG);
              return;
            }
            removeGrids();
            createPositionTable(positions);
            transUser = new Label("\"" + displayName + "\"持仓情况如下:");
            getItself().add(transUser);
            getItself().add(positionGrid);
          }
        };
    // Make the call to the stock price service.
    stockSvc.getStockPositions(username, callback);
  }