@Override
  public void init(TaskCommentsPresenter presenter) {
    this.presenter = presenter;
    listContainer.add(commentsListGrid);
    listContainer.add(pager);
    commentsAccordionLabel.add(new HTMLPanel(constants.Add_Comment()));
    commentsListGrid.setHeight("350px");
    commentsListGrid.setEmptyTableWidget(new HTMLPanel(constants.No_Comments_For_This_Task()));
    // Attach a column sort handler to the ListDataProvider to sort the list.
    sortHandler = new ListHandler<CommentSummary>(presenter.getDataProvider().getList());
    commentsListGrid.addColumnSortHandler(sortHandler);
    initTableColumns();
    presenter.addDataDisplay(commentsListGrid);
    // Create a Pager to control the table.
    pager.setDisplay(commentsListGrid);
    pager.setPageSize(COMMENTS_PER_PAGE);
    adjustDisplayForListOfSize(1);

    newTaskCommentTextArea.setWidth("300px");
    addCommentButton.setText(constants.Add_Comment());
    newTaskCommentLabel.setText(constants.Comment());
  }
  private void initTableColumns() {
    // addedBy
    Column<CommentSummary, String> addedByColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary c) {
            // for some reason the username comes in format [User:'******'], so parse just the
            // <name>
            int first = c.getAddedBy().indexOf('\'');
            int last = c.getAddedBy().lastIndexOf('\'');
            return c.getAddedBy().substring(first + 1, last);
          }
        };
    addedByColumn.setSortable(false);
    commentsListGrid.addColumn(addedByColumn, constants.Added_By());
    commentsListGrid.setColumnWidth(addedByColumn, "100px");

    // date
    Column<CommentSummary, String> addedAtColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary c) {
            DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy HH:mm");
            return format.format(c.getAddedAt());
          }
        };
    addedAtColumn.setSortable(true);
    addedAtColumn.setDefaultSortAscending(true);
    commentsListGrid.addColumn(addedAtColumn, constants.At());
    sortHandler.setComparator(
        addedAtColumn,
        new Comparator<CommentSummary>() {
          @Override
          public int compare(CommentSummary o1, CommentSummary o2) {
            return o1.getAddedAt().compareTo(o2.getAddedAt());
          }
        });

    // comment text
    Column<CommentSummary, String> commentTextColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary object) {
            return object.getText();
          }
        };
    addedByColumn.setSortable(false);
    commentsListGrid.addColumn(commentTextColumn, constants.Comment());

    List<HasCell<CommentSummary, ?>> cells = new LinkedList<HasCell<CommentSummary, ?>>();

    cells.add(
        new DeleteCommentActionHasCell(
            constants.Delete(),
            new Delegate<CommentSummary>() {
              @Override
              public void execute(CommentSummary comment) {
                presenter.removeTaskComment(comment.getId());
              }
            }));

    CompositeCell<CommentSummary> cell = new CompositeCell<CommentSummary>(cells);
    Column<CommentSummary, CommentSummary> actionsColumn =
        new Column<CommentSummary, CommentSummary>(cell) {
          @Override
          public CommentSummary getValue(CommentSummary object) {
            return object;
          }
        };
    commentsListGrid.addColumn(actionsColumn, "");
  }