FileDocCategorySizeDatePackage
DynaTableWidget.javaAPI DocExample8651Mon Aug 27 20:11:36 BST 2007com.google.gwt.sample.dynatable.client

DynaTableWidget

public class DynaTableWidget extends com.google.gwt.user.client.ui.Composite
A composite Widget that implements the main interface for the dynamic table, including the data table, status indicators, and paging buttons.

Fields Summary
private static final String
NO_CONNECTION_MESSAGE
private final com.google.gwt.sample.dynatable.client.DynaTableDataProvider.RowDataAcceptor
acceptor
private final com.google.gwt.user.client.ui.Grid
grid
private final NavBar
navbar
private ErrorDialog
errorDialog
private final com.google.gwt.user.client.ui.DockPanel
outer
private final DynaTableDataProvider
provider
private int
startRow
Constructors Summary
public DynaTableWidget(DynaTableDataProvider provider, String[] columns, String[] columnStyles, int rowCount)


      
          

    if (columns.length == 0) {
      throw new IllegalArgumentException(
          "expecting a positive number of columns");
    }

    if (columnStyles != null && columns.length != columnStyles.length) {
      throw new IllegalArgumentException("expecting as many styles as columns");
    }

    this.provider = provider;
    initWidget(outer);
    grid.setStyleName("table");
    outer.add(navbar, DockPanel.NORTH);
    outer.add(grid, DockPanel.CENTER);
    initTable(columns, columnStyles, rowCount);
    setStyleName("DynaTable-DynaTableWidget");
  
Methods Summary
public voidclearStatusText()

    navbar.status.setHTML(" ");
  
private intgetDataRowCount()

    return grid.getRowCount() - 1;
  
private voidinitTable(java.lang.String[] columns, java.lang.String[] columnStyles, int rowCount)

    // Set up the header row. It's one greater than the number of visible rows.
    //
    grid.resize(rowCount + 1, columns.length);
    for (int i = 0, n = columns.length; i < n; i++) {
      grid.setText(0, i, columns[i]);
      if (columnStyles != null) {
        grid.getCellFormatter().setStyleName(0, i, columnStyles[i] + " header");
      }
    }
  
public voidrefresh()

    // Disable buttons temporarily to stop the user from running off the end.
    //
    navbar.gotoFirst.setEnabled(false);
    navbar.gotoPrev.setEnabled(false);
    navbar.gotoNext.setEnabled(false);

    setStatusText("Please wait...");
    provider.updateRowData(startRow, grid.getRowCount() - 1, acceptor);
  
public voidsetRowCount(int rows)

    grid.resizeRows(rows);
  
public voidsetStatusText(java.lang.String text)

    navbar.status.setText(text);