The Unified and Autonomous Development Platform
go go go
robin shine7defa472d2a7
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/MentionParser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/MentionParser.javasimilarity index 96%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/comment/MentionParser.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/MentionParser.javaindex 9a5617086a..52c3ce56d2 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/MentionParser.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/MentionParser.java@@ -1,4 +1,4 @@-package com.pmease.gitplex.core.comment;+package com.pmease.gitplex.core;import java.util.Collection;import java.util.HashSet;@@ -14,7 +14,6 @@ import org.jsoup.select.NodeTraversor;import com.google.common.collect.ImmutableSet;import com.pmease.commons.util.JsoupUtils;import com.pmease.commons.util.TextNodeVisitor;-import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.manager.UserManager;import com.pmease.gitplex.core.model.User;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.javadeleted file mode 100644index 93e518b9d9..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java+++ /dev/null@@ -1,42 +0,0 @@-package com.pmease.gitplex.core.comment;--import java.io.Serializable;-import java.util.Collection;-import java.util.Date;--import javax.annotation.Nullable;--import com.pmease.gitplex.core.model.Repository;-import com.pmease.gitplex.core.model.User;--public interface Comment extends Serializable {- Long getId();-- User getUser();-- Date getDate();-- String getContent();-- void saveContent(String content);-- Repository getRepository();-- void delete();-- Collection<? extends CommentReply> getReplies();-- CommentReply loadReply(Long replyId);-- CommentReply addReply(String content);-- /**- * Get last visit date of this comment for current user.- *- * @return- * last visit date of this comment for current user, or <tt>null</tt>- * if current user is anonymous or has never visited the comment- */- @Nullable- Date getLastVisitDate();-}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentReply.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentReply.javadeleted file mode 100644index 75b794a1c1..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentReply.java+++ /dev/null@@ -1,22 +0,0 @@-package com.pmease.gitplex.core.comment;--import java.io.Serializable;-import java.util.Date;--import com.pmease.gitplex.core.model.User;--public interface CommentReply extends Serializable {- Long getId();-- Comment getComment();-- User getUser();-- Date getDate();-- String getContent();-- void saveContent(String content);-- void delete();-}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.javadeleted file mode 100644index e6705f0cd3..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java+++ /dev/null@@ -1,11 +0,0 @@-package com.pmease.gitplex.core.comment;--import com.pmease.commons.git.BlobIdent;--public interface InlineComment extends Comment {-- BlobIdent getBlobIdent();-- int getLine();--}\ No newline at end of filediff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.javadeleted file mode 100644index 0a24ce504d..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java+++ /dev/null@@ -1,19 +0,0 @@-package com.pmease.gitplex.core.comment;--import java.io.Serializable;-import java.util.List;-import java.util.Map;--import com.pmease.commons.git.BlobIdent;--public interface InlineCommentSupport extends Serializable {-- Map<Integer, List<InlineComment>> getComments(BlobIdent blobIdent);-- InlineComment addComment(BlobIdent commentAt, BlobIdent compareWith,- int line, String content);-- InlineComment getConcernedComment();-- InlineComment loadComment(Long commentId);-}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.javaindex 5e07978a10..cdfface969 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.java@@ -1,5 +1,7 @@package com.pmease.gitplex.core.manager;+import com.pmease.commons.git.BlobIdent;+import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestComment;public interface PullRequestCommentManager {@@ -14,4 +16,5 @@ public interface PullRequestCommentManager {void save(PullRequestComment comment, boolean notify);+ void addInline(PullRequest request, BlobIdent blobInfo, BlobIdent compareWith, int line, String content);}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.javaindex 621ea71924..06e1bb1bd9 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java@@ -83,4 +83,5 @@ public interface PullRequestManager extends ConfigListener {*/@NullableDate getLastVisitDate(PullRequest request);+}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.javaindex 2c368e4522..a0c3165b54 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java@@ -3,6 +3,7 @@ package com.pmease.gitplex.core.manager.impl;import static com.pmease.gitplex.core.model.PullRequestComment.DIFF_CONTEXT_SIZE;import java.util.Collection;+import java.util.Date;import java.util.List;import java.util.Set;@@ -21,9 +22,11 @@ import com.pmease.commons.lang.diff.DiffBlock;import com.pmease.commons.lang.diff.DiffMatchPatch.Operation;import com.pmease.commons.lang.diff.DiffUtils;import com.pmease.commons.markdown.MarkdownManager;-import com.pmease.gitplex.core.comment.MentionParser;+import com.pmease.gitplex.core.MentionParser;import com.pmease.gitplex.core.listeners.PullRequestListener;import com.pmease.gitplex.core.manager.PullRequestCommentManager;+import com.pmease.gitplex.core.manager.UserManager;+import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.core.model.User;@@ -32,14 +35,17 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManagprivate final Dao dao;+ private final UserManager userManager;+private final Set<PullRequestListener> pullRequestListeners;private final MarkdownManager markdownManager;@Inject- public DefaultPullRequestCommentManager(Dao dao, MarkdownManager markdownManager,+ public DefaultPullRequestCommentManager(Dao dao, UserManager userManager, MarkdownManager markdownManager,Set<PullRequestListener> pullRequestListeners) {this.dao = dao;+ this.userManager = userManager;this.markdownManager = markdownManager;this.pullRequestListeners = pullRequestListeners;}@@ -49,10 +55,14 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManagpublic void updateInlineInfo(PullRequestComment comment) {Preconditions.checkNotNull(comment.getInlineInfo());+ System.err.println("updating inline info...");+String latestCommitHash = comment.getRequest().getLatestUpdate().getHeadCommitHash();if (!comment.getNewCommitHash().equals(latestCommitHash)) {try {+ System.err.println("sleeping...");Thread.sleep(10000);+ System.err.println("sleeped.");} catch (InterruptedException e) {}@@ -166,7 +176,7 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManagcomment.getBlobIdent().revision = latestCommitHash;}}- dao.persist(comment);+ dao.persist(comment);}}@@ -191,4 +201,21 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag}}+ @Transactional+ @Override+ public void addInline(PullRequest request, BlobIdent blobInfo, BlobIdent compareWith, int line, String content) {+ User user = userManager.getCurrent();+ Preconditions.checkNotNull(user);+ PullRequestComment comment = new PullRequestComment();+ request.getComments().add(comment);+ comment.setUser(user);+ comment.setDate(new Date());+ comment.setContent(content);+ comment.setRequest(request);+ comment.setBlobIdent(blobInfo);+ comment.setCompareWith(compareWith);+ comment.setLine(line);+ save(comment, true);+ }+}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentReplyManager.javaindex e037353bdf..43af4f5177 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentReplyManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentReplyManager.java@@ -13,7 +13,7 @@ import com.pmease.commons.hibernate.Transactional;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.commons.markdown.MarkdownManager;-import com.pmease.gitplex.core.comment.MentionParser;+import com.pmease.gitplex.core.MentionParser;import com.pmease.gitplex.core.listeners.PullRequestListener;import com.pmease.gitplex.core.manager.PullRequestCommentReplyManager;import com.pmease.gitplex.core.model.PullRequest;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.javaindex 78ad37eac3..38ec3c172e 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java@@ -49,7 +49,7 @@ import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.commons.markdown.MarkdownManager;import com.pmease.commons.util.FileUtils;-import com.pmease.gitplex.core.comment.MentionParser;+import com.pmease.gitplex.core.MentionParser;import com.pmease.gitplex.core.listeners.LifecycleListener;import com.pmease.gitplex.core.listeners.PullRequestListener;import com.pmease.gitplex.core.listeners.RepositoryListener;@@ -101,7 +101,7 @@ public class DefaultPullRequestManager implements PullRequestManager, Repositoryprivate final ReviewInvitationManager reviewInvitationManager;- private final Set<Long> integrationPreviewRequestIds = new ConcurrentHashSet<>();+ private final Set<Long> integrationPreviewCalculatingRequestIds = new ConcurrentHashSet<>();private ThreadPoolExecutor integrationPreviewExecutor;@@ -524,8 +524,8 @@ public class DefaultPullRequestManager implements PullRequestManager, Repositorypublic void run() {unitOfWork.begin();try {- if (!integrationPreviewRequestIds.contains(requestId)) {- integrationPreviewRequestIds.add(requestId);+ if (!integrationPreviewCalculatingRequestIds.contains(requestId)) {+ integrationPreviewCalculatingRequestIds.add(requestId);try {PullRequest request = dao.load(PullRequest.class, requestId);IntegrationPreview preview = request.getLastIntegrationPreview();@@ -602,7 +602,7 @@ public class DefaultPullRequestManager implements PullRequestManager, Repositorylistener.onIntegrationPreviewCalculated(request);}} finally {- integrationPreviewRequestIds.remove(requestId);+ integrationPreviewCalculatingRequestIds.remove(requestId);}}} catch (Exception e) {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.javaindex 1a790e9d81..6009eced2a 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java@@ -895,5 +895,5 @@ public class PullRequest extends AbstractEntity {return GitPlex.getInstance().guessServerUrl() + "/" + getTargetRepo().getFQN()+ "/pull_requests/" + getId() + "/overview";}-+}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.javaindex d4523b4c97..a60d423481 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java@@ -25,15 +25,13 @@ import com.pmease.commons.hibernate.AbstractEntity;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.util.Pair;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.comment.CommentReply;-import com.pmease.gitplex.core.comment.InlineComment;import com.pmease.gitplex.core.manager.PullRequestCommentReplyManager;import com.pmease.gitplex.core.manager.PullRequestManager;import com.pmease.gitplex.core.manager.UserManager;@SuppressWarnings("serial")@Entity-public class PullRequestComment extends AbstractEntity implements InlineComment {+public class PullRequestComment extends AbstractEntity {public static final int DIFF_CONTEXT_SIZE = 3;@@ -69,7 +67,6 @@ public class PullRequestComment extends AbstractEntity implements InlineComment}@Nullable- @Overridepublic User getUser() {return user;}@@ -78,7 +75,6 @@ public class PullRequestComment extends AbstractEntity implements InlineCommentthis.user = user;}- @Overridepublic String getContent() {return content;}@@ -87,7 +83,6 @@ public class PullRequestComment extends AbstractEntity implements InlineCommentthis.content = content;}- @Overridepublic Date getDate() {return date;}@@ -96,29 +91,24 @@ public class PullRequestComment extends AbstractEntity implements InlineCommentthis.date = date;}- @Overridepublic void saveContent(String content) {setContent(content);GitPlex.getInstance(Dao.class).persist(this);}- @Overridepublic Repository getRepository() {return request.getTargetRepo();}- @Overridepublic void delete() {GitPlex.getInstance(Dao.class).remove(this);}- @Overridepublic Collection<PullRequestCommentReply> getReplies() {return request.getCommentReplies(this);}- @Override- public CommentReply addReply(String content) {+ public PullRequestCommentReply addReply(String content) {User user = GitPlex.getInstance(UserManager.class).getCurrent();Preconditions.checkNotNull(user);PullRequestCommentReply reply = new PullRequestCommentReply();@@ -166,7 +156,6 @@ public class PullRequestComment extends AbstractEntity implements InlineCommentreturn getOldAndNew().getSecond();}- @Overridepublic BlobIdent getBlobIdent() {return Preconditions.checkNotNull(inlineInfo).getBlobIdent();}@@ -187,7 +176,6 @@ public class PullRequestComment extends AbstractEntity implements InlineCommentinlineInfo.setCompareWith(compareWith);}- @Overridepublic int getLine() {return Preconditions.checkNotNull(inlineInfo).getLine();}@@ -198,14 +186,8 @@ public class PullRequestComment extends AbstractEntity implements InlineCommentinlineInfo.setLine(line);}- @Overridepublic Date getLastVisitDate() {return GitPlex.getInstance(PullRequestManager.class).getLastVisitDate(getRequest());}- @Override- public CommentReply loadReply(Long replyId) {- return GitPlex.getInstance(Dao.class).load(PullRequestCommentReply.class, replyId);- }-}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.javaindex d27cfca46f..56db2b0ca5 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.java@@ -11,11 +11,10 @@ import javax.persistence.ManyToOne;import com.pmease.commons.hibernate.AbstractEntity;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.comment.CommentReply;@SuppressWarnings("serial")@Entity-public class PullRequestCommentReply extends AbstractEntity implements CommentReply {+public class PullRequestCommentReply extends AbstractEntity {@ManyToOne(fetch=FetchType.LAZY)@JoinColumn(nullable=false)@@ -55,18 +54,15 @@ public class PullRequestCommentReply extends AbstractEntity implements CommentRethis.content = content;}- @Overridepublic void saveContent(String content) {setContent(content);GitPlex.getInstance(Dao.class).persist(this);}- @Overridepublic void delete() {GitPlex.getInstance(Dao.class).remove(this);}- @Overridepublic PullRequestComment getComment() {return comment;}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.javaindex 1bfa86a64d..c5b52bab8a 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java@@ -8,9 +8,9 @@ import com.pmease.commons.git.Git;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.comment.Comment;import com.pmease.gitplex.core.manager.UserManager;import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.core.model.RepoAndBranch;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.core.model.Review;@@ -50,7 +50,7 @@ public class SecurityUtils extends org.apache.shiro.SecurityUtils {}}- public static boolean canModify(Comment comment) {+ public static boolean canModify(PullRequestComment comment) {User currentUser = GitPlex.getInstance(UserManager.class).getCurrent();if (currentUser == null) {return false;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.javaindex 25f9c41b46..4a8b1e2882 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java@@ -20,7 +20,7 @@ import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.html.panel.Panel;+import org.apache.wicket.markup.html.panel.GenericPanel;import org.apache.wicket.markup.repeater.RepeatingView;import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;@@ -29,6 +29,7 @@ import org.apache.wicket.model.Model;import org.apache.wicket.request.resource.CssResourceReference;import org.apache.wicket.util.time.Duration;+import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.loader.InheritableThreadLocalData;import com.pmease.commons.wicket.behavior.ConfirmBehavior;import com.pmease.commons.wicket.behavior.DirtyIgnoreBehavior;@@ -36,9 +37,9 @@ import com.pmease.commons.wicket.component.feedback.FeedbackPanel;import com.pmease.commons.wicket.component.markdown.MarkdownPanel;import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior.PageId;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.comment.Comment;-import com.pmease.gitplex.core.comment.CommentReply;import com.pmease.gitplex.core.manager.UserManager;+import com.pmease.gitplex.core.model.PullRequestComment;+import com.pmease.gitplex.core.model.PullRequestCommentReply;import com.pmease.gitplex.core.security.SecurityUtils;import com.pmease.gitplex.web.component.avatar.AvatarMode;import com.pmease.gitplex.web.component.userlink.UserLink;@@ -47,7 +48,7 @@ import com.pmease.gitplex.web.page.repository.pullrequest.PullRequestChanged;import com.pmease.gitplex.web.utils.DateUtils;@SuppressWarnings("serial")-public class CommentPanel extends Panel {+public class CommentPanel extends GenericPanel<PullRequestComment> {private static final String HEAD_ID = "head";@@ -59,15 +60,15 @@ public class CommentPanel extends Panel {private RepeatingView repliesView;- private final IModel<List<CommentReply>> repliesModel = new LoadableDetachableModel<List<CommentReply>>() {+ private final IModel<List<PullRequestCommentReply>> repliesModel = new LoadableDetachableModel<List<PullRequestCommentReply>>() {@Override- protected List<CommentReply> load() {- List<CommentReply> replies = new ArrayList<>(getComment().getReplies());- Collections.sort(replies, new Comparator<CommentReply>() {+ protected List<PullRequestCommentReply> load() {+ List<PullRequestCommentReply> replies = new ArrayList<>(getComment().getReplies());+ Collections.sort(replies, new Comparator<PullRequestCommentReply>() {@Override- public int compare(CommentReply reply1, CommentReply reply2) {+ public int compare(PullRequestCommentReply reply1, PullRequestCommentReply reply2) {return reply1.getDate().compareTo(reply2.getDate());}@@ -77,12 +78,12 @@ public class CommentPanel extends Panel {};- public CommentPanel(String id, IModel<? extends Comment> commentModel) {+ public CommentPanel(String id, IModel<PullRequestComment> commentModel) {super(id, commentModel);}- private Comment getComment() {- return (Comment) getDefaultModelObject();+ private PullRequestComment getComment() {+ return getModelObject();}private Fragment renderForView(String content) {@@ -121,7 +122,7 @@ public class CommentPanel extends Panel {@Overrideprotected void onSubmit(AjaxRequestTarget target, Form<?> form) {- Comment comment = getComment();+ PullRequestComment comment = getComment();comment.saveContent(input.getModelObject());Fragment fragment = renderForView(comment.getContent());@@ -179,10 +180,10 @@ public class CommentPanel extends Panel {}.add(new ConfirmBehavior("Deleting this comment will also delete all its replies. Do you really want to continue?")));- head.add(newAdditionalCommentOperations("additionalOperations", new AbstractReadOnlyModel<Comment>() {+ head.add(newAdditionalCommentOperations("additionalOperations", new AbstractReadOnlyModel<PullRequestComment>() {@Override- public Comment getObject() {+ public PullRequestComment getObject() {return getComment();}@@ -204,15 +205,15 @@ public class CommentPanel extends Panel {if (event.getPayload() instanceof PullRequestChanged) {PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();AjaxRequestTarget target = pullRequestChanged.getTarget();- List<CommentReply> replies = repliesModel.getObject();+ List<PullRequestCommentReply> replies = repliesModel.getObject();Date lastReplyDate;if (repliesView.size() != 0) {Component lastReplyRow = repliesView.get(repliesView.size()-1);- lastReplyDate = ((CommentReply)lastReplyRow.getDefaultModelObject()).getDate();+ lastReplyDate = ((PullRequestCommentReply)lastReplyRow.getDefaultModelObject()).getDate();} else {lastReplyDate = getComment().getDate();}- for (CommentReply reply: replies) {+ for (PullRequestCommentReply reply: replies) {if (reply.getDate().after(lastReplyDate)) {Component newReplyRow = newReplyRow(repliesView.newChildId(), reply);repliesView.add(newReplyRow);@@ -260,7 +261,7 @@ public class CommentPanel extends Panel {CommentPanel.this.replace(addReply);target.add(addReply);- CommentReply reply;+ PullRequestCommentReply reply;InheritableThreadLocalData.set(new PageId(pageId));try {reply = getComment().addReply(input.getModelObject());@@ -307,7 +308,7 @@ public class CommentPanel extends Panel {private RepeatingView newRepliesView() {RepeatingView repliesView = new RepeatingView("replies");- for (CommentReply reply: repliesModel.getObject())+ for (PullRequestCommentReply reply: repliesModel.getObject())repliesView.add(newReplyRow(repliesView.newChildId(), reply));return repliesView;@@ -320,13 +321,13 @@ public class CommentPanel extends Panel {super.onBeforeRender();}- private Component newReplyRow(String id, CommentReply reply) {+ private Component newReplyRow(String id, PullRequestCommentReply reply) {final Long replyId = reply.getId();- final WebMarkupContainer row = new WebMarkupContainer(id, new LoadableDetachableModel<CommentReply>() {+ final WebMarkupContainer row = new WebMarkupContainer(id, new LoadableDetachableModel<PullRequestCommentReply>() {@Override- protected CommentReply load() {- return getComment().loadReply(replyId);+ protected PullRequestCommentReply load() {+ return GitPlex.getInstance(Dao.class).load(PullRequestCommentReply.class, replyId);}});@@ -346,7 +347,7 @@ public class CommentPanel extends Panel {Form<?> form = new Form<Void>("form");fragment.add(form);- CommentReply reply = (CommentReply) row.getDefaultModelObject();+ PullRequestCommentReply reply = (PullRequestCommentReply) row.getDefaultModelObject();final CommentInput input = new CommentInput("input", Model.of(reply.getContent()));input.setRequired(true);form.add(input);@@ -356,7 +357,7 @@ public class CommentPanel extends Panel {@Overrideprotected void onSubmit(AjaxRequestTarget target, Form<?> form) {- CommentReply reply = (CommentReply) row.getDefaultModelObject();+ PullRequestCommentReply reply = (PullRequestCommentReply) row.getDefaultModelObject();reply.saveContent(input.getModelObject());Fragment fragment = renderForView(reply.getContent());@@ -376,7 +377,7 @@ public class CommentPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {- CommentReply reply = (CommentReply) row.getDefaultModelObject();+ PullRequestCommentReply reply = (PullRequestCommentReply) row.getDefaultModelObject();Fragment fragment = renderForView(reply.getContent());row.replace(fragment);target.add(fragment);@@ -402,7 +403,7 @@ public class CommentPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {- CommentReply reply = (CommentReply) row.getDefaultModelObject();+ PullRequestCommentReply reply = (PullRequestCommentReply) row.getDefaultModelObject();reply.delete();row.remove();target.appendJavaScript(String.format("$('#%s').remove();", row.getMarkupId()));@@ -417,7 +418,7 @@ public class CommentPanel extends Panel {}.add(new ConfirmBehavior("Do you really want to delete this reply?")));- row.add(newAdditionalReplyOperations("additionalOperations", (CommentReply) row.getDefaultModelObject()));+ row.add(newAdditionalReplyOperations("additionalOperations", (PullRequestCommentReply) row.getDefaultModelObject()));row.add(new WebMarkupContainer("anchor").add(AttributeModifier.replace("name", "reply" + reply.getId())));row.add(renderForView(reply.getContent()));@@ -431,11 +432,11 @@ public class CommentPanel extends Panel {return row;}- protected Component newAdditionalCommentOperations(String id, IModel<Comment> comment) {+ protected Component newAdditionalCommentOperations(String id, IModel<PullRequestComment> comment) {return new WebMarkupContainer(id);}- protected Component newAdditionalReplyOperations(String id, CommentReply reply) {+ protected Component newAdditionalReplyOperations(String id, PullRequestCommentReply reply) {return new WebMarkupContainer(id);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentRemoved.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentRemoved.javaindex 3eea504d7b..cf8fc88ea8 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentRemoved.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentRemoved.java@@ -3,19 +3,19 @@ package com.pmease.gitplex.web.component.comment;import org.apache.wicket.ajax.AjaxRequestTarget;import com.pmease.commons.wicket.AjaxEvent;-import com.pmease.gitplex.core.comment.Comment;+import com.pmease.gitplex.core.model.PullRequestComment;public class CommentRemoved extends AjaxEvent {- private final Comment comment;+ private final PullRequestComment comment;- public CommentRemoved(AjaxRequestTarget target, Comment comment) {+ public CommentRemoved(AjaxRequestTarget target, PullRequestComment comment) {super(target);this.comment = comment;}- public Comment getComment() {+ public PullRequestComment getComment() {return comment;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/MentionTransformer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/MentionTransformer.javaindex 2c470fedcb..976a774d06 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/MentionTransformer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/MentionTransformer.java@@ -4,7 +4,7 @@ import org.apache.wicket.request.cycle.RequestCycle;import org.jsoup.nodes.Element;import com.pmease.commons.markdown.extensionpoint.HtmlTransformer;-import com.pmease.gitplex.core.comment.MentionParser;+import com.pmease.gitplex.core.MentionParser;import com.pmease.gitplex.core.model.User;import com.pmease.gitplex.web.page.account.AccountPage;import com.pmease.gitplex.web.page.account.repositories.AccountReposPage;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.javaindex 153bfae9fe..cb76d726c6 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java@@ -1,7 +1,5 @@package com.pmease.gitplex.web.component.diff.blob;-import javax.annotation.Nullable;-import org.apache.wicket.behavior.AttributeAppender;import org.apache.wicket.markup.head.CssHeaderItem;import org.apache.wicket.markup.head.IHeaderResponse;@@ -17,7 +15,8 @@ import com.pmease.commons.git.Blob;import com.pmease.commons.git.BlobChange;import com.pmease.commons.lang.diff.DiffUtils;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.comment.InlineCommentSupport;+import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.Constants;import com.pmease.gitplex.web.component.diff.blob.text.TextDiffPanel;@@ -31,20 +30,23 @@ public class BlobDiffPanel extends Panel {private final IModel<Repository> repoModel;+ private final IModel<PullRequest> requestModel;++ private final IModel<PullRequestComment> commentModel;+private final BlobChange change;private final DiffMode diffMode;- private final InlineCommentSupport commentSupport;-- public BlobDiffPanel(String id, IModel<Repository> repoModel, BlobChange change,- DiffMode diffMode, @Nullable InlineCommentSupport commentSupport) {+ public BlobDiffPanel(String id, IModel<Repository> repoModel, IModel<PullRequest> requestModel,+ IModel<PullRequestComment> commentModel, BlobChange change, DiffMode diffMode) {super(id);this.repoModel = repoModel;+ this.requestModel = requestModel;+ this.commentModel = commentModel;this.change = change;this.diffMode = diffMode;- this.commentSupport = commentSupport;}private Fragment newFragment(String message, boolean warning) {@@ -70,7 +72,7 @@ public class BlobDiffPanel extends Panel {elseadd(newFragment("Empty file added.", false));} else {- add(new TextDiffPanel(CONTENT_ID, repoModel, change, diffMode, commentSupport));+ add(new TextDiffPanel(CONTENT_ID, repoModel, requestModel, commentModel, change, diffMode));}} else if (blob.isPartial()) {add(newFragment("File is too large to be loaded.", true));@@ -105,7 +107,7 @@ public class BlobDiffPanel extends Panel {} else if (change.getAdditions() + change.getDeletions() == 0) {add(newFragment("File is identical if " + change.getLineProcessor().getName().toLowerCase() + ".", false));} else {- add(new TextDiffPanel(CONTENT_ID, repoModel, change, diffMode, commentSupport));+ add(new TextDiffPanel(CONTENT_ID, repoModel, requestModel, commentModel, change, diffMode));}} else if (change.getOldBlob().isPartial() || change.getNewBlob().isPartial()) {add(newFragment("File is too large to be loaded.", true));@@ -134,6 +136,8 @@ public class BlobDiffPanel extends Panel {protected void onDetach() {repoModel.detach();+ requestModel.detach();+ commentModel.detach();super.onDetach();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.javaindex 13958af9b2..b81854b5fd 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.java@@ -2,13 +2,13 @@ package com.pmease.gitplex.web.component.diff.blob.text;import java.io.Serializable;-import com.pmease.gitplex.core.comment.InlineComment;+import com.pmease.gitplex.core.model.PullRequestComment;-class CommentAndPos implements Serializable {+public class CommentAndPos implements Serializable {private static final long serialVersionUID = 1L;- InlineComment comment;+ PullRequestComment comment;int oldLineNo;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.javaindex 2f8b28f2a8..6d52604d5d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java@@ -8,8 +8,6 @@ import java.util.LinkedHashMap;import java.util.List;import java.util.Map;-import javax.annotation.Nullable;-import org.apache.wicket.Component;import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;import org.apache.wicket.ajax.AjaxRequestTarget;@@ -41,17 +39,20 @@ import org.apache.wicket.util.time.Duration;import com.pmease.commons.git.BlobChange;import com.pmease.commons.git.BlobIdent;+import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.lang.diff.DiffBlock;import com.pmease.commons.lang.diff.DiffMatchPatch.Operation;import com.pmease.commons.lang.diff.DiffUtils;import com.pmease.commons.lang.diff.LineDiff;import com.pmease.commons.lang.tokenizers.CmToken;+import com.pmease.commons.loader.InheritableThreadLocalData;import com.pmease.commons.util.StringUtils;import com.pmease.commons.wicket.behavior.DirtyIgnoreBehavior;import com.pmease.commons.wicket.component.feedback.FeedbackPanel;-import com.pmease.gitplex.core.comment.Comment;-import com.pmease.gitplex.core.comment.InlineComment;-import com.pmease.gitplex.core.comment.InlineCommentSupport;+import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;+import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.Constants;@@ -73,38 +74,41 @@ public class TextDiffPanel extends Panel {private final IModel<Repository> repoModel;+ private final IModel<PullRequest> requestModel;++ private final IModel<PullRequestComment> commentModel;+private final BlobChange change;private final Map<Integer, Integer> contextSizes = new HashMap<>();private final DiffMode diffMode;- private final InlineCommentSupport commentSupport;-private final IModel<List<CommentAndPos>> listOfCommentAndPosModel = new LoadableDetachableModel<List<CommentAndPos>>() {@Overrideprotected List<CommentAndPos> load() {List<CommentAndPos> listOfCommentAndPos = new ArrayList<>();- if (commentSupport != null) {- for (Map.Entry<Integer, List<InlineComment>> entry:- commentSupport.getComments(change.getOldBlobIdent()).entrySet()) {- for (InlineComment each: entry.getValue()) {- CommentAndPos commentAndPos = new CommentAndPos();- commentAndPos.comment = each;- commentAndPos.oldLineNo = entry.getKey();- commentAndPos.newLineNo = -1;- listOfCommentAndPos.add(commentAndPos);- }- }- for (Map.Entry<Integer, List<InlineComment>> entry:- commentSupport.getComments(change.getNewBlobIdent()).entrySet()) {- for (InlineComment each: entry.getValue()) {- CommentAndPos commentAndPos = new CommentAndPos();- commentAndPos.comment = each;- commentAndPos.oldLineNo = -1;- commentAndPos.newLineNo = entry.getKey();- listOfCommentAndPos.add(commentAndPos);+ if (requestModel.getObject() != null) {+ PullRequest request = requestModel.getObject();+ for (PullRequestComment comment: request.getComments()) {+ if (comment.getInlineInfo() != null) {+ GitPlex.getInstance(PullRequestCommentManager.class).updateInlineInfo(comment);+ BlobIdent blobIdent = comment.getBlobIdent();+ if (blobIdent.equals(change.getOldBlobIdent())) {+ CommentAndPos commentAndPos = new CommentAndPos();+ commentAndPos.comment = comment;+ commentAndPos.oldLineNo = comment.getLine();+ commentAndPos.newLineNo = -1;+ listOfCommentAndPos.add(commentAndPos);+ }+ if (blobIdent.equals(change.getNewBlobIdent())) {+ CommentAndPos commentAndPos = new CommentAndPos();+ commentAndPos.comment = comment;+ commentAndPos.oldLineNo = -1;+ commentAndPos.newLineNo = comment.getLine();+ listOfCommentAndPos.add(commentAndPos);+ }}}Collections.sort(listOfCommentAndPos, new Comparator<CommentAndPos>() {@@ -127,14 +131,15 @@ public class TextDiffPanel extends Panel {private RepeatingView commentRows;- public TextDiffPanel(String id, IModel<Repository> repoModel, BlobChange change, DiffMode diffMode,- @Nullable InlineCommentSupport commentSupport) {+ public TextDiffPanel(String id, IModel<Repository> repoModel, IModel<PullRequest> requestModel,+ IModel<PullRequestComment> commentModel, BlobChange change, DiffMode diffMode) {super(id);this.repoModel = repoModel;+ this.commentModel = commentModel;+ this.requestModel = requestModel;this.change = change;this.diffMode = diffMode;- this.commentSupport = commentSupport;}@Override@@ -242,7 +247,13 @@ public class TextDiffPanel extends Panel {lineNo = newLineNo;}- commentSupport.addComment(commentAt, compareWith, lineNo, input.getModelObject());+ InheritableThreadLocalData.set(new WebSocketRenderBehavior.PageId(getPage().getPageId()));+ try {+ GitPlex.getInstance(PullRequestCommentManager.class).addInline(+ requestModel.getObject(), commentAt, compareWith, lineNo, input.getModelObject());+ } finally {+ InheritableThreadLocalData.clear();+ }CommentAndPos lastComment = listOfCommentAndPosModel.getObject().get(listOfCommentAndPosModel.getObject().size()-1);Component commentRow = newCommentRow(commentRows.newChildId(), lastComment);@@ -418,7 +429,7 @@ public class TextDiffPanel extends Panel {}private void appendAddComment(StringBuilder builder, int oldLineNo, int newLineNo) {- if (commentSupport != null) {+ if (commentModel.getObject() != null) {builder.append("<span class='add-comment'>");String script = String.format("document.getElementById('%s').addComment(%d, %d);",getMarkupId(), oldLineNo, newLineNo);@@ -618,8 +629,8 @@ public class TextDiffPanel extends Panel {public void renderHead(IHeaderResponse response) {super.renderHead(response);- if (commentSupport.getConcernedComment() != null- && commentId.equals(commentSupport.getConcernedComment().getId())) {+ PullRequestComment comment = commentModel.getObject();+ if (comment != null && commentId.equals(comment.getId())) {String script = String.format("$('#%s').closest('td').focus();", getMarkupId());response.render(OnDomReadyHeaderItem.forScript(script));}@@ -627,17 +638,15 @@ public class TextDiffPanel extends Panel {};row.add(new UserLink("avatar", new UserModel(commentAndPos.comment.getUser()), AvatarMode.AVATAR));- row.add(new CommentPanel("detail", new LoadableDetachableModel<Comment>() {+ row.add(new CommentPanel("detail", new LoadableDetachableModel<PullRequestComment>() {@Override- protected Comment load() {- return commentSupport.loadComment(commentId);+ protected PullRequestComment load() {+ return GitPlex.getInstance(Dao.class).load(PullRequestComment.class, commentId);}}));- if (commentAndPos.comment.equals(commentSupport.getConcernedComment()))- row.add(AttributeAppender.append("class", " concerned"));row.add(AttributeAppender.append("data-oldLineNo", commentAndPos.oldLineNo));row.add(AttributeAppender.append("data-newLineNo", commentAndPos.newLineNo));row.setOutputMarkupId(true);@@ -648,6 +657,8 @@ public class TextDiffPanel extends Panel {@Overrideprotected void onDetach() {repoModel.detach();+ requestModel.detach();+ commentModel.detach();listOfCommentAndPosModel.detach();super.onDetach();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.javaindex 277db14e33..d5059726d3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java@@ -32,14 +32,15 @@ import org.eclipse.jgit.diff.DiffEntry;import org.eclipse.jgit.diff.DiffEntry.ChangeType;import com.pmease.commons.git.Blob;-import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.BlobChange;+import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.LineProcessor;import com.pmease.commons.lang.diff.DiffUtils;import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.comment.InlineCommentSupport;+import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.Constants;import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;@@ -50,6 +51,10 @@ public abstract class RevisionDiffPanel extends Panel {private final IModel<Repository> repoModel;+ private final IModel<PullRequest> requestModel;++ private final IModel<PullRequestComment> commentModel;+private final String oldRev;private final String newRev;@@ -62,9 +67,6 @@ public abstract class RevisionDiffPanel extends Panel {private final DiffMode diffMode;- @Nullable- private final InlineCommentSupport commentSupport;-private IModel<ChangesAndCount> changesAndCountModel = new LoadableDetachableModel<ChangesAndCount>() {@Override@@ -167,19 +169,20 @@ public abstract class RevisionDiffPanel extends Panel {}};- public RevisionDiffPanel(String id, IModel<Repository> repoModel, String oldRev, String newRev,- @Nullable String path, @Nullable String comparePath, LineProcessor lineProcessor,- DiffMode diffMode, @Nullable InlineCommentSupport commentSupport) {+ public RevisionDiffPanel(String id, IModel<Repository> repoModel, IModel<PullRequest> requestModel,+ IModel<PullRequestComment> commentModel, String oldRev, String newRev, @Nullable String path,+ @Nullable String comparePath, LineProcessor lineProcessor, DiffMode diffMode) {super(id);this.repoModel = repoModel;+ this.requestModel = requestModel;+ this.commentModel = commentModel;this.oldRev = oldRev;this.newRev = newRev;this.path = path;this.comparePath = comparePath;this.lineProcessor = lineProcessor;this.diffMode = diffMode;- this.commentSupport = commentSupport;}@Override@@ -291,7 +294,7 @@ public abstract class RevisionDiffPanel extends Panel {BlobChange change = item.getModelObject();item.setMarkupId("diff-" + change.getPath());item.setOutputMarkupId(true);- item.add(new BlobDiffPanel("change", repoModel, change, diffMode, commentSupport));+ item.add(new BlobDiffPanel("change", repoModel, requestModel, commentModel, change, diffMode));}});@@ -309,6 +312,8 @@ public abstract class RevisionDiffPanel extends Panel {protected void onDetach() {changesAndCountModel.detach();repoModel.detach();+ requestModel.detach();+ commentModel.detach();super.onDetach();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.javaindex 6188c584e3..3dec859b99 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java@@ -50,6 +50,7 @@ import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequest.CloseStatus;import com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy;import com.pmease.gitplex.core.model.PullRequest.Status;+import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.core.model.PullRequestUpdate;import com.pmease.gitplex.core.model.RepoAndBranch;import com.pmease.gitplex.core.model.Repository;@@ -368,9 +369,9 @@ public class NewRequestPage extends PullRequestPage {PullRequest request = getPullRequest();String oldRev = request.getBaseCommitHash();String newRev = request.getLatestUpdate().getHeadCommitHash();- RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", repoModel,- oldRev, newRev, path, null, diffOption.getLineProcessor(),- diffOption.getDiffMode(), null) {+ RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", repoModel, new Model<PullRequest>(null),+ new Model<PullRequestComment>(null), oldRev, newRev, path, null, diffOption.getLineProcessor(),+ diffOption.getDiffMode()) {@Overrideprotected void onClearPath(AjaxRequestTarget target) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.javaindex b7097e5533..3a2def0b7d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java@@ -2,8 +2,6 @@ package com.pmease.gitplex.web.page.repository.pullrequest.requestdetail.compareimport java.io.Serializable;import java.util.ArrayList;-import java.util.Date;-import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;@@ -30,13 +28,10 @@ import org.apache.wicket.request.cycle.RequestCycle;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.apache.wicket.request.resource.CssResourceReference;-import com.google.common.base.Preconditions;-import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.Commit;import com.pmease.commons.git.GitUtils;import com.pmease.commons.hibernate.HibernateUtils;import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.commons.loader.InheritableThreadLocalData;import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;import com.pmease.commons.wicket.behavior.StickyBehavior;@@ -46,18 +41,12 @@ import com.pmease.commons.wicket.behavior.dropdown.DropdownPanel;import com.pmease.commons.wicket.behavior.menu.MenuBehavior;import com.pmease.commons.wicket.behavior.menu.MenuItem;import com.pmease.commons.wicket.behavior.menu.MenuPanel;-import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.comment.InlineComment;-import com.pmease.gitplex.core.comment.InlineCommentSupport;-import com.pmease.gitplex.core.manager.PullRequestCommentManager;-import com.pmease.gitplex.core.manager.UserManager;import com.pmease.gitplex.core.model.IntegrationPreview;import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.core.model.PullRequestUpdate;import com.pmease.gitplex.core.model.Repository;-import com.pmease.gitplex.core.model.User;import com.pmease.gitplex.web.component.comment.CommentRemoved;import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;import com.pmease.gitplex.web.component.diff.revision.option.DiffOptionPanel;@@ -113,7 +102,7 @@ public class RequestComparePage extends RequestDetailPage {protected PullRequestComment load() {if (state.commentId != null)return GitPlex.getInstance(Dao.class).load(PullRequestComment.class, state.commentId);- else+ elsereturn null;}@@ -185,7 +174,7 @@ public class RequestComparePage extends RequestDetailPage {private void initFromState(HistoryState state) {PullRequest request = getPullRequest();PullRequestComment comment = commentModel.getObject();- if (comment != null) {+ if (comment != null && comment.getId() != null) {oldCommitHash = comment.getOldCommitHash();newCommitHash = comment.getNewCommitHash();path = comment.getBlobIdent().path;@@ -761,74 +750,26 @@ public class RequestComparePage extends RequestDetailPage {}private void newCompareResult(@Nullable AjaxRequestTarget target) {- InlineCommentSupport commentSupport;-- List<String> commentables = getPullRequest().getCommentables();- int oldCommitIndex = commentables.indexOf(oldCommitHash);- int newCommitIndex = commentables.indexOf(newCommitHash);- if (oldCommitIndex == -1 || newCommitIndex == -1 || oldCommitIndex > newCommitIndex) {- commentSupport = null;- } else {- commentSupport = new InlineCommentSupport() {-- @Override- public Map<Integer, List<InlineComment>> getComments(BlobIdent blobIdent) {- Map<Integer, List<InlineComment>> comments = new HashMap<>();- for (PullRequestComment comment: getPullRequest().getComments()) {- if (comment.getInlineInfo() != null) {-// GitPlex.getInstance(PullRequestCommentManager.class).updateInlineInfo(comment);- if (comment.getBlobIdent().equals(blobIdent)) {- List<InlineComment> commentsAtLine = comments.get(comment.getLine());- if (commentsAtLine == null) {- commentsAtLine = new ArrayList<>();- comments.put(comment.getLine(), commentsAtLine);- }- commentsAtLine.add(comment);- }- }- }- return comments;- }-- @Override- public InlineComment getConcernedComment() {- return commentModel.getObject();- }-- @Override- public InlineComment addComment(BlobIdent blobInfo, BlobIdent compareWith,- int line, String content) {- User user = GitPlex.getInstance(UserManager.class).getCurrent();- Preconditions.checkNotNull(user);- PullRequestComment comment = new PullRequestComment();- getPullRequest().getComments().add(comment);- comment.setUser(user);- comment.setDate(new Date());- comment.setContent(content);- comment.setRequest(getPullRequest());- comment.setBlobIdent(blobInfo);- comment.setCompareWith(compareWith);- comment.setLine(line);- InheritableThreadLocalData.set(new WebSocketRenderBehavior.PageId(getPageId()));- try {- GitPlex.getInstance(PullRequestCommentManager.class).save(comment, true);- } finally {- InheritableThreadLocalData.clear();- }- return comment;- }+ IModel<PullRequest> requestModel = new LoadableDetachableModel<PullRequest>() {- @Override- public InlineComment loadComment(Long commentId) {- return GitPlex.getInstance(Dao.class).load(PullRequestComment.class, commentId);+ @Override+ protected PullRequest load() {+ PullRequest request = getPullRequest();+ List<String> commentables = request.getCommentables();+ int oldCommitIndex = commentables.indexOf(oldCommitHash);+ int newCommitIndex = commentables.indexOf(newCommitHash);+ if (oldCommitIndex == -1 || newCommitIndex == -1 || oldCommitIndex > newCommitIndex) {+ // indicate that comment support is not available in text diff panel+ return null;+ } else {+ return request;}- };+ }+};-- compareResult = new RevisionDiffPanel("compareResult",- repoModel, oldCommitHash, newCommitHash, path, comparePath,- diffOption.getLineProcessor(), diffOption.getDiffMode(),- commentSupport) {++ compareResult = new RevisionDiffPanel("compareResult", repoModel, requestModel, commentModel, oldCommitHash, newCommitHash,+ path, comparePath, diffOption.getLineProcessor(), diffOption.getDiffMode()) {@Overrideprotected void onClearPath(AjaxRequestTarget target) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentActivityPanel.javaindex 8ae8b5d31f..4f183278a9 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentActivityPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentActivityPanel.java@@ -5,10 +5,9 @@ import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;-import com.pmease.gitplex.core.comment.Comment;-import com.pmease.gitplex.core.comment.CommentReply;import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestComment;+import com.pmease.gitplex.core.model.PullRequestCommentReply;import com.pmease.gitplex.web.component.comment.CommentPanel;@SuppressWarnings("serial")@@ -29,7 +28,7 @@ class CommentActivityPanel extends Panel {add(new CommentPanel("content", commentModel) {@Override- protected Component newAdditionalCommentOperations(String id, final IModel<Comment> commentModel) {+ protected Component newAdditionalCommentOperations(String id, final IModel<PullRequestComment> commentModel) {return new SinceChangesLink(id, new AbstractReadOnlyModel<PullRequest>() {@Override@@ -41,7 +40,7 @@ class CommentActivityPanel extends Panel {}@Override- protected Component newAdditionalReplyOperations(String id, CommentReply reply) {+ protected Component newAdditionalReplyOperations(String id, PullRequestCommentReply reply) {return new SinceChangesLink(id, new AbstractReadOnlyModel<PullRequest>() {@Override