@Override
  protected void createComment(String commentText) {
    if (comment != null) {
      comment.setBody(commentText);

      new EditCommentTask(this, repositoryId, comment) {
        @Override
        protected void onSuccess(Comment comment) throws Exception {
          super.onSuccess(comment);

          finish(comment);
        }
      }.start();
    } else {
      new CreateCommentTask(this, repositoryId, issueNumber, commentText) {

        @Override
        protected void onSuccess(Comment comment) throws Exception {
          super.onSuccess(comment);

          finish(comment);
        }
      }.start();
    }
  }
 @Override
 protected CommentPreviewPagerAdapter createAdapter() {
   CommentPreviewPagerAdapter commentPreviewPagerAdapter =
       new CommentPreviewPagerAdapter(this, repositoryId);
   commentPreviewPagerAdapter.setCommentText(comment != null ? comment.getBody() : null);
   return commentPreviewPagerAdapter;
 }
Exemplo n.º 3
0
  protected void updateComment(final Comment comment) {
    imageGetter.bind(textView(0), comment.getBodyHtml(), comment.getId());
    avatars.bind(imageView(3), comment.getUser());

    setText(1, comment.getUser().getLogin());
    setText(2, TimeUtils.getRelativeTime(comment.getUpdatedAt()));

    final boolean canEdit =
        (isOwner || comment.getUser().getLogin().equals(userName)) && editCommentListener != null;

    final boolean canDelete =
        (isOwner || comment.getUser().getLogin().equals(userName)) && deleteCommentListener != null;

    final ImageView ivMore = view(4);

    if (!canEdit && !canDelete) ivMore.setVisibility(View.INVISIBLE);
    else
      ivMore.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              showMorePopup(ivMore, comment, canEdit, canDelete);
            }
          });
  }
  @NbBundle.Messages({
    "GitHubIssueController.edit.comment.title=Edit Comment",
    "GitHubIssueController.edit.comment.fail=Can't edit this comment."
  })
  private void editComment() {
    final Comment comment = getPanel().getEditedComment();
    final String editedBody =
        CommentTabbedPanel.showDialog(
            Bundle.GitHubIssueController_edit_comment_title(), comment.getBody());
    if (editedBody != null) {
      final GitHubIssue issue = getPanel().getIssue();
      if (issue != null) {
        RequestProcessor rp = GitHubIssues.getInstance().getRequestProcessor();
        rp.post(
            new Runnable() {

              @Override
              public void run() {
                Comment editedComment = issue.editComment(comment, editedBody);
                if (editedComment == null) {
                  UiUtils.showErrorDialog(Bundle.GitHubIssueController_edit_comment_fail());
                  return;
                }
                SwingUtilities.invokeLater(
                    new Runnable() {

                      @Override
                      public void run() {
                        getPanel().loadComments();
                      }
                    });
              }
            });
      }
    }
  }