Пример #1
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);
  }
Пример #2
0
  public void initColumns() {
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return object.getTitle();
          }
        },
        "Title");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return object.getOwnerName();
          }
        },
        "Owner name");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return object.getViews();
          }
        },
        "Views");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return DateTimeFormat.getFormat("dd-MM-yyyy HH:mm").format(object.getDateupload());
          }
        },
        "Date Upload");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return DateTimeFormat.getFormat("dd-MM-yyyy HH:mm").format(object.getLastupdate());
          }
        },
        "Last Update");
    cellTable.addColumn(
        new Column<Photo, String>(new ImageCell(75, 75)) {
          @Override
          public String getValue(Photo object) {
            return object.getUrl();
          }
        },
        "Photo");

    cellTable.addCellPreviewHandler(
        new CellPreviewEvent.Handler<Photo>() {
          @Override
          public void onCellPreview(CellPreviewEvent<Photo> event) {
            if (event.getNativeEvent().getType().equals("mousedown")) {
              Photo photo = event.getValue();
              AppContext.getInstance().getEventBus().fireEvent(new ShowPhotoDialog(photo));
            }
          }
        });
  }