private void initMockData(
     final Pagination pagination,
     final SimplePager simplePager,
     final ListDataProvider<TableTestPojo> dataProvider) {
   for (int i = 0; i < 25; i++) {
     dataProvider.getList().add(new TableTestPojo("Test " + i, "Test " + i, "Test " + i));
   }
   dataProvider.flush();
   pagination.rebuild(simplePager);
 }
  private void initTable(
      final AbstractCellTable<TableTestPojo> grid,
      final SimplePager pager,
      final Pagination pagination,
      final ListDataProvider<TableTestPojo> dataProvider) {
    final TextColumn<TableTestPojo> col1 =
        new TextColumn<TableTestPojo>() {

          @Override
          public String getValue(final TableTestPojo object) {
            return String.valueOf(object.getField1());
          }
        };
    grid.addColumn(col1, "Field 1");

    final TextColumn<TableTestPojo> col2 =
        new TextColumn<TableTestPojo>() {

          @Override
          public String getValue(final TableTestPojo object) {
            return String.valueOf(object.getField1());
          }
        };
    grid.addColumn(col2, "Field 2");

    final TextColumn<TableTestPojo> col3 =
        new TextColumn<TableTestPojo>() {

          @Override
          public String getValue(final TableTestPojo object) {
            return String.valueOf(object.getField1());
          }
        };
    grid.addColumn(col3, "Field 3");

    grid.addRangeChangeHandler(
        new RangeChangeEvent.Handler() {

          @Override
          public void onRangeChange(final RangeChangeEvent event) {
            pagination.rebuild(pager);
          }
        });

    pager.setDisplay(grid);
    pagination.clear();
    dataProvider.addDataDisplay(grid);
  }
示例#3
0
  public void setup() {
    // BZ-996917: Use a the gwtboostrap style "row-fluid" to allow display some events in the same
    // row.
    eventTypes.setStyleName(Styles.ROW);

    // Fill panel with available events.
    for (Map.Entry<String, Boolean> e :
        auditLog.getAuditLogFilter().getAcceptedTypes().entrySet()) {
      eventTypes.add(makeEventTypeCheckBox(e.getKey(), e.getValue()));
    }

    // Create the GWT Cell Table as events container.
    // BZ-996942: Set custom width and table css style.
    events = new CellTable<AuditLogEntry>();
    events.setWidth("100%");
    events.addStyleName(Styles.TABLE);

    final ListDataProvider<AuditLogEntry> dlp =
        new ListDataProvider<AuditLogEntry>(filterDeletedEntries(auditLog));
    dlp.addDataDisplay(events);

    AuditLogEntrySummaryColumn summaryColumn =
        new AuditLogEntrySummaryColumn(style.auditLogDetailLabel(), style.auditLogDetailValue());
    AuditLogEntryCommentColumn commentColumn = new AuditLogEntryCommentColumn();

    events.addColumn(summaryColumn);
    events.addColumn(commentColumn);

    events.setColumnWidth(summaryColumn, 60.0, Unit.PCT);
    events.setColumnWidth(commentColumn, 40.0, Unit.PCT);

    // If the current user is not an Administrator include the delete comment column
    if (identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) {

      AuditLogEntryDeleteCommentColumn deleteCommentColumn = new AuditLogEntryDeleteCommentColumn();
      deleteCommentColumn.setFieldUpdater(
          new FieldUpdater<AuditLogEntry, SafeHtml>() {

            public void update(int index, AuditLogEntry row, SafeHtml value) {
              row.setDeleted(true);
              dlp.setList(filterDeletedEntries(auditLog));
              dlp.refresh();
            }
          });
      events.addColumn(deleteCommentColumn);
      events.setColumnWidth(commentColumn, 35.0, Unit.PCT);
      events.setColumnWidth(deleteCommentColumn, 5.0, Unit.PCT);
    }

    events.setEmptyTableWidget(
        new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogNoEntries()));
    events.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE);
    events.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    events.setPageSize(PAGE_SIZE);

    // Configure the simple pager.
    pager.setDisplay(events);
    pager.setPageSize(PAGE_SIZE);

    events.addRangeChangeHandler(
        new RangeChangeEvent.Handler() {
          @Override
          public void onRangeChange(final RangeChangeEvent event) {
            cellTablePagination.rebuild(pager);
          }
        });

    cellTablePagination.rebuild(pager);

    // Add the table to the container.
    eventsContainer.add(events);
  }