示例#1
0
  private void setupSessionDataGrid() {
    sessionsDataGrid = new DataGrid<SessionDataDto>();
    sessionsDataGrid.setPageSize(15);
    sessionsDataGrid.setEmptyTableWidget(new Label("No Sessions"));

    // Add a selection model so we can select cells.
    final SelectionModel<SessionDataDto> selectionModel =
        new MultiSelectionModel<SessionDataDto>(
            new ProvidesKey<SessionDataDto>() {
              @Override
              public Object getKey(SessionDataDto item) {
                return item.getSessionId();
              }
            });
    sessionsDataGrid.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<SessionDataDto>createCheckboxManager());

    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable mouse selection.
    Column<SessionDataDto, Boolean> checkColumn =
        new Column<SessionDataDto, Boolean>(new CheckboxCell(true, false)) {
          @Override
          public Boolean getValue(SessionDataDto object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };
    sessionsDataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    sessionsDataGrid.setColumnWidth(checkColumn, 40, Style.Unit.PX);

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getName();
          }
        },
        "Name");

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getStartDate();
          }
        },
        "Start Date");

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getEndDate();
          }
        },
        "End Date");

    sessionDataProvider.addDataDisplay(sessionsDataGrid);
  }
示例#2
0
  private void setupTestDataGrid() {
    testDataGrid = new CellTable<TaskDataDto>();
    testDataGrid.setWidth("500px");
    testDataGrid.setEmptyTableWidget(new Label("No Tests"));

    // Add a selection model so we can select cells.
    final SelectionModel<TaskDataDto> selectionModel =
        new MultiSelectionModel<TaskDataDto>(
            new ProvidesKey<TaskDataDto>() {
              @Override
              public Object getKey(TaskDataDto item) {
                return item.getTaskName();
              }
            });
    testDataGrid.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<TaskDataDto>createCheckboxManager());

    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable mouse selection.
    Column<TaskDataDto, Boolean> checkColumn =
        new Column<TaskDataDto, Boolean>(new CheckboxCell(true, false)) {
          @Override
          public Boolean getValue(TaskDataDto object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };
    testDataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    testDataGrid.setColumnWidth(checkColumn, 40, Style.Unit.PX);

    testDataGrid.addColumn(
        new TextColumn<TaskDataDto>() {
          @Override
          public String getValue(TaskDataDto object) {
            return object.getTaskName();
          }
        },
        "Tests");
    testDataGrid.setRowData(Collections.EMPTY_LIST);
  }