Skip to content

The Unified and Autonomous Development Platform

Refactor DiffMark as CommentPos

robin shine23bfb122c4a2
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
index 6321818bf7..ee5e86f39d 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
@@ -23,13 +23,11 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.annotations.DynamicUpdate;
-import org.hibernate.annotations.OptimisticLock;
import com.pmease.commons.hibernate.AbstractEntity;
-import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.core.entity.component.CompareContext;
-import com.pmease.gitplex.core.entity.component.Mark;
import com.pmease.gitplex.core.manager.VisitInfoManager;
import com.pmease.gitplex.core.security.SecurityUtils;
@@ -71,17 +69,9 @@ public class CodeComment extends AbstractEntity {
private String lastReplyUser;
- @OptimisticLock(excluded=true)
- @Column(nullable=false)
- private String commit;
-
- @OptimisticLock(excluded=true)
- private String path;
-
- @OptimisticLock(excluded=true)
@Embedded
- private Mark mark;
-
+ private CommentPos commentPos;
+
@Embedded
private CompareContext compareContext;
@@ -152,36 +142,12 @@ public class CodeComment extends AbstractEntity {
this.createDate = createDate;
}
- public void delete() {
- GitPlex.getInstance(Dao.class).remove(this);
- }
-
- public String getCommit() {
- return commit;
- }
-
- public void setCommit(String commit) {
- this.commit = commit;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public void setDate(Date date) {
- this.createDate = date;
- }
-
- public Mark getMark() {
- return mark;
+ public CommentPos getCommentPos() {
+ return commentPos;
}
- public void setMark(Mark mark) {
- this.mark = mark;
+ public void setCommentPos(CommentPos commentPos) {
+ this.commentPos = commentPos;
}
public CompareContext getCompareContext() {
@@ -251,7 +217,7 @@ public class CodeComment extends AbstractEntity {
}
public ComparingInfo getComparingInfo() {
- return new ComparingInfo(commit, compareContext);
+ return new ComparingInfo(commentPos.getCommit(), compareContext);
}
public static class ComparingInfo implements Serializable {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java
index bd5e3aa6d0..2b1b5da092 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java
@@ -112,7 +112,7 @@ public class CodeCommentReply extends AbstractEntity {
}
public ComparingInfo getComparingInfo() {
- return new ComparingInfo(comment.getCommit(), compareContext);
+ return new ComparingInfo(comment.getCommentPos().getCommit(), compareContext);
}
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/CommentPos.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/CommentPos.java
new file mode 100644
index 0000000000..04d9ec3dd7
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/CommentPos.java
@@ -0,0 +1,118 @@
+package com.pmease.gitplex.core.entity.component;
+
+import java.io.Serializable;
+
+import javax.annotation.Nullable;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.hibernate.annotations.OptimisticLock;
+
+@Embeddable
+public class CommentPos implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @OptimisticLock(excluded=true)
+ @Column(nullable=false)
+ private String commit;
+
+ @OptimisticLock(excluded=true)
+ private String path;
+
+ @OptimisticLock(excluded=true)
+ private TextRange range;
+
+ public String getCommit() {
+ return commit;
+ }
+
+ public void setCommit(String commit) {
+ this.commit = commit;
+ }
+
+ @Nullable
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Nullable
+ public TextRange getRange() {
+ return range;
+ }
+
+ public void setRange(TextRange range) {
+ this.range = range;
+ }
+
+ public CommentPos() {
+ }
+
+ public CommentPos(String commit, @Nullable String path, @Nullable TextRange mark) {
+ this.commit = commit;
+ this.path = path;
+ this.range = mark;
+ }
+
+ @Override
+ public String toString() {
+ if (range != null)
+ return commit + ":" + path + ":" + range;
+ else if (path != null)
+ return commit + ":" + path;
+ else
+ return commit;
+ }
+
+ public static CommentPos fromString(String str) {
+ String commit = StringUtils.substringBefore(str, ":");
+ String path = null;
+ TextRange mark = null;
+ String pathAndMark = StringUtils.substringAfter(str, ":");
+ if (pathAndMark.length() != 0) {
+ path = StringUtils.substringBefore(pathAndMark, ":");
+ String markStr = StringUtils.substringAfter(pathAndMark, ":");
+ if (markStr.length() != 0)
+ mark = new TextRange(markStr);
+ }
+ return new CommentPos(commit, path, mark);
+ }
+
+ public static CommentPos of(@Nullable String str) {
+ if (str != null)
+ return fromString(str);
+ else
+ return null;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof CommentPos))
+ return false;
+ if (this == other)
+ return true;
+ CommentPos otherPos = (CommentPos) other;
+ return new EqualsBuilder()
+ .append(commit, otherPos.commit)
+ .append(path, otherPos.path)
+ .append(range, otherPos.range)
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(commit)
+ .append(path)
+ .append(range)
+ .toHashCode();
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/Mark.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
similarity index 67%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/Mark.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
index c76a22e7f9..ffac11aa4c 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/Mark.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
@@ -10,35 +10,35 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import com.pmease.commons.lang.extractors.TokenPosition;
-public class Mark implements Serializable {
+public class TextRange implements Serializable {
private static final long serialVersionUID = 1L;
public int beginLine, beginChar, endLine, endChar;
- public Mark() {
+ public TextRange() {
}
- public Mark(int beginLine, int beginChar, int endLine, int endChar) {
+ public TextRange(int beginLine, int beginChar, int endLine, int endChar) {
this.beginLine = beginLine;
this.beginChar = beginChar;
this.endLine = endLine;
this.endChar = endChar;
}
- public Mark(Mark mark) {
- this.beginLine = mark.beginLine;
- this.beginChar = mark.beginChar;
- this.endLine = mark.endLine;
- this.endChar = mark.endChar;
+ public TextRange(TextRange range) {
+ this.beginLine = range.beginLine;
+ this.beginChar = range.beginChar;
+ this.endLine = range.endLine;
+ this.endChar = range.endChar;
}
- public Mark(TokenPosition tokenPos) {
+ public TextRange(TokenPosition tokenPos) {
this(tokenPos.getLine(), tokenPos.getRange().getFrom(),
tokenPos.getLine(), tokenPos.getRange().getTo());
}
- public Mark(String markStr) {
+ public TextRange(String markStr) {
String begin = StringUtils.substringBefore(markStr, "-");
String end = StringUtils.substringAfter(markStr, "-");
beginLine = Integer.parseInt(StringUtils.substringBefore(begin, "."))-1;
@@ -70,16 +70,16 @@ public class Mark implements Serializable {
@Override
public boolean equals(Object other) {
- if (!(other instanceof Mark))
+ if (!(other instanceof TextRange))
return false;
if (this == other)
return true;
- Mark otherMark = (Mark) other;
+ TextRange otherRange = (TextRange) other;
return new EqualsBuilder()
- .append(beginLine, otherMark.beginLine)
- .append(beginChar, otherMark.beginChar)
- .append(endLine, otherMark.endLine)
- .append(endChar, otherMark.endChar)
+ .append(beginLine, otherRange.beginLine)
+ .append(beginChar, otherRange.beginChar)
+ .append(endLine, otherRange.endLine)
+ .append(endChar, otherRange.endChar)
.isEquals();
}
@@ -93,16 +93,16 @@ public class Mark implements Serializable {
.toHashCode();
}
- public static @Nullable Mark of(@Nullable TokenPosition tokenPos) {
+ public static @Nullable TextRange of(@Nullable TokenPosition tokenPos) {
if (tokenPos != null)
- return new Mark(tokenPos);
+ return new TextRange(tokenPos);
else
return null;
}
- public static @Nullable Mark of(@Nullable String markStr) {
- if (markStr != null)
- return new Mark(markStr);
+ public static @Nullable TextRange of(@Nullable String str) {
+ if (str != null)
+ return new TextRange(str);
else
return null;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentInfoManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentInfoManager.java
index a4ad3cbbd7..51786e759c 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentInfoManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentInfoManager.java
@@ -216,7 +216,7 @@ public class DefaultCodeCommentInfoManager implements CodeCommentInfoManager, De
ByteIterable key = new StringByteIterable(comment.getUUID());
byte[] keyBytes = new byte[20];
- ObjectId.fromString(comment.getCommit()).copyRawTo(keyBytes, 0);
+ ObjectId.fromString(comment.getCommentPos().getCommit()).copyRawTo(keyBytes, 0);
ByteIterable commitKey = new ArrayByteIterable(keyBytes);
byte[] valueBytes = getBytes(store.get(txn, commitKey));
Map<String, CompareContext> comments;
@@ -227,14 +227,14 @@ public class DefaultCodeCommentInfoManager implements CodeCommentInfoManager, De
comments.put(comment.getUUID(), comment.getCompareContext());
store.put(txn, commitKey, new ArrayByteIterable(SerializationUtils.serialize((Serializable) comments)));
- if (comment.getPath() != null) {
+ if (comment.getCommentPos().getPath() != null) {
Set<String> files;
valueBytes = getBytes(store.get(txn, FILES_KEY));
if (valueBytes != null)
files = (Set<String>) SerializationUtils.deserialize(valueBytes);
else
files = new HashSet<String>();
- files.add(comment.getPath());
+ files.add(comment.getCommentPos().getPath());
store.put(txn, FILES_KEY, new ArrayByteIterable(SerializationUtils.serialize((Serializable) files)));
filesCache.remove(depot.getId());
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.java
index c7cdb3c14e..d62da834ad 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.java
@@ -52,9 +52,9 @@ public class DefaultCodeCommentManager extends AbstractEntityDao<CodeComment> im
public Collection<CodeComment> query(Depot depot, ObjectId commitId, String path) {
EntityCriteria<CodeComment> criteria = newCriteria();
criteria.add(Restrictions.eq("depot", depot));
- criteria.add(Restrictions.eq("commit", commitId.name()));
+ criteria.add(Restrictions.eq("commentPos.commit", commitId.name()));
if (path != null)
- criteria.add(Restrictions.eq("path", path));
+ criteria.add(Restrictions.eq("commentPos.path", path));
return query(criteria);
}
@@ -67,7 +67,7 @@ public class DefaultCodeCommentManager extends AbstractEntityDao<CodeComment> im
criteria.add(Restrictions.eq("depot", depot));
List<Criterion> criterions = new ArrayList<>();
for (ObjectId commitId: commitIds) {
- criterions.add(Restrictions.eq("commit", commitId.name()));
+ criterions.add(Restrictions.eq("commentPos.commit", commitId.name()));
}
criteria.add(Restrictions.or(criterions.toArray(new Criterion[criterions.size()])));
return query(criteria);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilterOption.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilterOption.java
index 276216c17d..e336168e55 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilterOption.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilterOption.java
@@ -155,14 +155,14 @@ public class CodeCommentFilterOption implements Serializable {
continue;
}
if (path != null) {
- if (comment.getPath() == null) {
+ if (comment.getCommentPos().getPath() == null) {
it.remove();
continue;
} else {
String matchWith = path;
if (matchWith.endsWith("/"))
matchWith += "*";
- if (!WildcardUtils.matchString(matchWith, comment.getPath())) {
+ if (!WildcardUtils.matchString(matchWith, comment.getCommentPos().getPath())) {
it.remove();
continue;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.java
index a6d2b538af..e2e3eab33f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.java
@@ -46,7 +46,6 @@ import com.pmease.gitplex.core.entity.component.DepotAndRevision;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.web.Constants;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
import com.pmease.gitplex.web.page.depot.DepotPage;
import com.pmease.gitplex.web.page.depot.compare.RevisionComparePage;
import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
@@ -162,7 +161,7 @@ public abstract class CodeCommentListPanel extends Panel {
}
RequestChangesPage.State state = new RequestChangesPage.State();
state.commentId = comment.getId();
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.oldCommit = comparingInfo.getOldCommit();
state.newCommit = comparingInfo.getNewCommit();
state.pathFilter = comparingInfo.getPathFilter();
@@ -176,16 +175,16 @@ public abstract class CodeCommentListPanel extends Panel {
} else {
compareContext = comment.getCompareContext();
}
- if (!compareContext.getCompareCommit().equals(comment.getCommit())) {
+ if (!compareContext.getCompareCommit().equals(comment.getCommentPos().getCommit())) {
RevisionComparePage.State state = new RevisionComparePage.State();
state.commentId = comment.getId();
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.compareWithMergeBase = false;
if (compareContext.isLeftSide()) {
state.leftSide = new DepotAndRevision(depot, compareContext.getCompareCommit());
- state.rightSide = new DepotAndRevision(depot, comment.getCommit());
+ state.rightSide = new DepotAndRevision(depot, comment.getCommentPos().getCommit());
} else {
- state.leftSide = new DepotAndRevision(depot, comment.getCommit());
+ state.leftSide = new DepotAndRevision(depot, comment.getCommentPos().getCommit());
state.rightSide = new DepotAndRevision(depot, compareContext.getCompareCommit());
}
state.tabPanel = RevisionComparePage.TabPanel.CHANGES;
@@ -194,11 +193,11 @@ public abstract class CodeCommentListPanel extends Panel {
setResponsePage(RevisionComparePage.class, RevisionComparePage.paramsOf(depot, state));
} else {
DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent.revision = comment.getCommit();
- state.blobIdent.path = comment.getPath();
+ state.blobIdent.revision = comment.getCommentPos().getCommit();
+ state.blobIdent.path = comment.getCommentPos().getPath();
state.blobIdent.mode = FileMode.TYPE_FILE;
state.commentId = comment.getId();
- state.mark = comment.getMark();
+ state.mark = comment.getCommentPos().getRange();
setResponsePage(DepotFilePage.class, DepotFilePage.paramsOf(depot, state));
}
}
@@ -208,10 +207,10 @@ public abstract class CodeCommentListPanel extends Panel {
link.add(new Label("title", comment.getTitle()));
link.add(new WebMarkupContainer("resolved").setVisible(comment.isResolved()));
link.add(new Label("user", comment.getUser().getDisplayName()));
- if (comment.getPath() != null)
- link.add(new Label("what", comment.getPath()));
+ if (comment.getCommentPos().getPath() != null)
+ link.add(new Label("what", comment.getCommentPos().getPath()));
else
- link.add(new Label("what", comment.getCommit()));
+ link.add(new Label("what", comment.getCommentPos().getCommit()));
link.add(new Label("age", DateUtils.formatAge(comment.getCreateDate())));
WebMarkupContainer lastReply = new WebMarkupContainer("lastReply");
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.java
index 78ebaa66e4..8907318064 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.java
@@ -46,7 +46,6 @@ import com.pmease.gitplex.core.manager.VisitInfoManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.web.component.AccountLink;
import com.pmease.gitplex.web.component.avatar.AvatarLink;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
import com.pmease.gitplex.web.page.depot.compare.RevisionComparePage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.changes.RequestChangesPage;
import com.pmease.gitplex.web.util.DateUtils;
@@ -104,12 +103,12 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
state.commentId = comment.getId();
if (compareContext.isLeftSide()) {
state.oldCommit = compareContext.getCompareCommit();
- state.newCommit = comment.getCommit();
+ state.newCommit = comment.getCommentPos().getCommit();
} else {
- state.oldCommit = comment.getCommit();
+ state.oldCommit = comment.getCommentPos().getCommit();
state.newCommit = compareContext.getCompareCommit();
}
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.pathFilter = compareContext.getPathFilter();
state.whitespaceOption = compareContext.getWhitespaceOption();
PageParameters params = RequestChangesPage.paramsOf(request, state);
@@ -120,12 +119,12 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
state.compareWithMergeBase = false;
if (compareContext.isLeftSide()) {
state.leftSide = new DepotAndRevision(comment.getDepot(), compareContext.getCompareCommit());
- state.rightSide = new DepotAndRevision(comment.getDepot(), comment.getCommit());
+ state.rightSide = new DepotAndRevision(comment.getDepot(), comment.getCommentPos().getCommit());
} else {
- state.leftSide = new DepotAndRevision(comment.getDepot(), comment.getCommit());
+ state.leftSide = new DepotAndRevision(comment.getDepot(), comment.getCommentPos().getCommit());
state.rightSide = new DepotAndRevision(comment.getDepot(), compareContext.getCompareCommit());
}
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.pathFilter = compareContext.getPathFilter();
state.tabPanel = RevisionComparePage.TabPanel.CHANGES;
state.whitespaceOption = compareContext.getWhitespaceOption();
@@ -334,12 +333,12 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
state.commentId = reply.getComment().getId();
if (compareContext.isLeftSide()) {
state.oldCommit = compareContext.getCompareCommit();
- state.newCommit = reply.getComment().getCommit();
+ state.newCommit = reply.getComment().getCommentPos().getCommit();
} else {
- state.oldCommit = reply.getComment().getCommit();
+ state.oldCommit = reply.getComment().getCommentPos().getCommit();
state.newCommit = compareContext.getCompareCommit();
}
- state.mark = new DiffMark(reply.getComment());
+ state.mark = reply.getComment().getCommentPos();
state.pathFilter = compareContext.getPathFilter();
state.whitespaceOption = compareContext.getWhitespaceOption();
PageParameters params = RequestChangesPage.paramsOf(request, state);
@@ -351,12 +350,12 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
state.compareWithMergeBase = false;
if (compareContext.isLeftSide()) {
state.leftSide = new DepotAndRevision(comment.getDepot(), compareContext.getCompareCommit());
- state.rightSide = new DepotAndRevision(comment.getDepot(), comment.getCommit());
+ state.rightSide = new DepotAndRevision(comment.getDepot(), comment.getCommentPos().getCommit());
} else {
- state.leftSide = new DepotAndRevision(comment.getDepot(), comment.getCommit());
+ state.leftSide = new DepotAndRevision(comment.getDepot(), comment.getCommentPos().getCommit());
state.rightSide = new DepotAndRevision(comment.getDepot(), compareContext.getCompareCommit());
}
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.pathFilter = compareContext.getPathFilter();
state.tabPanel = RevisionComparePage.TabPanel.CHANGES;
state.whitespaceOption = compareContext.getWhitespaceOption();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
index 56f7f658ff..57cf4e473c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
@@ -47,7 +47,7 @@ import com.pmease.commons.wicket.component.floating.FloatingPanel;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.SearchManager;
import com.pmease.gitplex.search.hit.QueryHit;
import com.pmease.gitplex.search.query.BlobQuery;
@@ -275,7 +275,7 @@ public abstract class InstantSearchPanel extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent.revision = revisionModel.getObject();
state.blobIdent.path = hit.getBlobPath();
- state.mark = Mark.of(hit.getTokenPos());
+ state.mark = TextRange.of(hit.getTokenPos());
state.requestId = PullRequest.idOf(requestModel.getObject());
PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), state);
CharSequence url = RequestCycle.get().urlFor(DepotFilePage.class, params);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java
index 9fb040161b..9d9b813425 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java
@@ -34,7 +34,7 @@ import com.pmease.commons.wicket.assets.uri.URIResourceReference;
import com.pmease.commons.wicket.component.EmphasizeAwareLabel;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.hit.FileHit;
import com.pmease.gitplex.search.hit.QueryHit;
import com.pmease.gitplex.search.hit.TextHit;
@@ -471,7 +471,7 @@ public abstract class SearchResultPanel extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.requestId = PullRequest.idOf(context.getPullRequest());
- state.mark = Mark.of(hit.getTokenPos());
+ state.mark = TextRange.of(hit.getTokenPos());
state.blobIdent.revision = context.getBlobIdent().revision;
state.blobIdent.path = hit.getBlobPath();
PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
index d11d2d3f9c..af5cd742af 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
@@ -15,7 +15,7 @@ import com.pmease.commons.wicket.component.menu.MenuLink;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.hit.QueryHit;
public interface BlobViewContext extends Serializable {
@@ -30,11 +30,11 @@ public interface BlobViewContext extends Serializable {
BlobIdent getBlobIdent();
@Nullable
- Mark getMark();
+ TextRange getMark();
- void onMark(AjaxRequestTarget target, Mark mark);
+ void onMark(AjaxRequestTarget target, TextRange mark);
- String getMarkUrl(Mark mark);
+ String getMarkUrl(TextRange mark);
Mode getMode();
@@ -54,7 +54,7 @@ public interface BlobViewContext extends Serializable {
void onCommentOpened(AjaxRequestTarget target, @Nullable CodeComment comment);
- void onAddComment(AjaxRequestTarget target, Mark mark);
+ void onAddComment(AjaxRequestTarget target, TextRange mark);
@Nullable
CodeComment getOpenComment();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
index 14920eafc8..70ee6de9d1 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
@@ -80,9 +80,10 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.core.entity.component.CompareContext;
import com.pmease.gitplex.core.entity.component.DepotAndRevision;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.search.hit.QueryHit;
@@ -92,7 +93,6 @@ import com.pmease.gitplex.web.component.comment.DepotAttachmentSupport;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext.Mode;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewPanel;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
import com.pmease.gitplex.web.component.revisionpicker.RevisionSelector;
import com.pmease.gitplex.web.component.symboltooltip.SymbolTooltipPanel;
import com.pmease.gitplex.web.page.depot.commit.CommitDetailPage;
@@ -238,13 +238,13 @@ public class SourceViewPanel extends BlobViewPanel {
target.appendJavaScript("gitplex.sourceview.onToggleOutline();");
}
- public void mark(AjaxRequestTarget target, Mark mark, boolean scroll) {
+ public void mark(AjaxRequestTarget target, TextRange mark, boolean scroll) {
String script = String.format("gitplex.sourceview.mark(%s, %s);",
getJson(mark), scroll);
target.appendJavaScript(script);
}
- private String getJson(Mark mark) {
+ private String getJson(TextRange mark) {
try {
return GitPlex.getInstance(ObjectMapper.class).writeValueAsString(mark);
} catch (JsonProcessingException e) {
@@ -256,7 +256,7 @@ public class SourceViewPanel extends BlobViewPanel {
protected void onInitialize() {
super.onInitialize();
- commentContainer = new WebMarkupContainer("comment", Model.of((Mark)null)) {
+ commentContainer = new WebMarkupContainer("comment", Model.of((TextRange)null)) {
@Override
public void renderHead(IHeaderResponse response) {
@@ -310,9 +310,9 @@ public class SourceViewPanel extends BlobViewPanel {
RevisionComparePage.State state = new RevisionComparePage.State();
CodeComment comment = context.getOpenComment();
state.commentId = comment.getId();
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.compareWithMergeBase = false;
- state.leftSide = new DepotAndRevision(context.getDepot(), comment.getCommit());
+ state.leftSide = new DepotAndRevision(context.getDepot(), comment.getCommentPos().getCommit());
state.rightSide = new DepotAndRevision(context.getDepot(), revision);
state.tabPanel = RevisionComparePage.TabPanel.CHANGES;
PageParameters params = RevisionComparePage.paramsOf(context.getDepot(), state);
@@ -328,11 +328,11 @@ public class SourceViewPanel extends BlobViewPanel {
@Override
public void onClick(AjaxRequestTarget target) {
CodeComment comment = context.getOpenComment();
- Mark mark;
+ TextRange mark;
if (comment != null) {
- mark = comment.getMark();
+ mark = comment.getCommentPos().getRange();
} else {
- mark = (Mark) commentContainer.getDefaultModelObject();
+ mark = (TextRange) commentContainer.getDefaultModelObject();
}
mark(target, mark, true);
context.onMark(target, mark);
@@ -358,7 +358,7 @@ public class SourceViewPanel extends BlobViewPanel {
state.blobIdent = new BlobIdent(context.getBlobIdent());
state.blobIdent.revision = context.getCommit().name();
state.commentId = context.getOpenComment().getId();
- state.mark = context.getOpenComment().getMark();
+ state.mark = context.getOpenComment().getCommentPos().getRange();
return urlFor(DepotFilePage.class, DepotFilePage.paramsOf(context.getDepot(), state)).toString();
} else {
return "";
@@ -502,7 +502,7 @@ public class SourceViewPanel extends BlobViewPanel {
target.appendJavaScript(script);
break;
case "openSelectionPopover":
- Mark mark = getMark(params, "param1", "param2", "param3", "param4");
+ TextRange mark = getMark(params, "param1", "param2", "param3", "param4");
script = String.format("gitplex.sourceview.openSelectionPopover(%s, '%s', %s);",
getJson(mark), context.getMarkUrl(mark),
SecurityUtils.getAccount()!=null);
@@ -575,13 +575,14 @@ public class SourceViewPanel extends BlobViewPanel {
CodeComment comment = new CodeComment();
comment.setUUID(uuid);
- comment.setCommit(context.getCommit().name());
- comment.setPath(context.getBlobIdent().path);
+ comment.setCommentPos(new CommentPos());
+ comment.getCommentPos().setCommit(context.getCommit().name());
+ comment.getCommentPos().setPath(context.getBlobIdent().path);
comment.setTitle(titleInput.getModelObject());
comment.setContent(contentInput.getModelObject());
comment.setDepot(context.getDepot());
comment.setUser(SecurityUtils.getAccount());
- comment.setMark(mark);
+ comment.getCommentPos().setRange(mark);
comment.setCompareContext(getCompareContext());
GitPlex.getInstance(CodeCommentManager.class).save(comment);
@@ -753,7 +754,7 @@ public class SourceViewPanel extends BlobViewPanel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent = context.getBlobIdent();
state.commentId = CodeComment.idOf(context.getOpenComment());
- state.mark = Mark.of(symbol.getPos());
+ state.mark = TextRange.of(symbol.getPos());
state.requestId = PullRequest.idOf(context.getPullRequest());
PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
link.add(AttributeAppender.replace("href", urlFor(DepotFilePage.class, params).toString()));
@@ -816,13 +817,13 @@ public class SourceViewPanel extends BlobViewPanel {
});
}
- private Mark getMark(IRequestParameters params, String beginLineParam, String beginCharParam,
+ private TextRange getMark(IRequestParameters params, String beginLineParam, String beginCharParam,
String endLineParam, String endCharParam) {
int beginLine = params.getParameterValue(beginLineParam).toInt();
int beginChar = params.getParameterValue(beginCharParam).toInt();
int endLine = params.getParameterValue(endLineParam).toInt();
int endChar = params.getParameterValue(endCharParam).toInt();
- Mark mark = new Mark();
+ TextRange mark = new TextRange();
mark.beginLine = beginLine;
mark.beginChar = beginChar;
mark.endLine = endLine;
@@ -833,7 +834,7 @@ public class SourceViewPanel extends BlobViewPanel {
private String getJsonOfComment(CodeComment comment) {
CommentInfo commentInfo = new CommentInfo();
commentInfo.id = comment.getId();
- commentInfo.mark = comment.getMark();
+ commentInfo.mark = comment.getCommentPos().getRange();
commentInfo.title = comment.getTitle();
String jsonOfCommentInfo;
@@ -928,8 +929,8 @@ public class SourceViewPanel extends BlobViewPanel {
String jsonOfBlameInfos = getJsonOfBlameInfos(context.getMode() == Mode.BLAME);
Map<Integer, List<CommentInfo>> commentInfos = new HashMap<>();
for (CodeComment comment: commentsModel.getObject()) {
- if (comment.getMark() != null) {
- int line = comment.getMark().getBeginLine();
+ if (comment.getCommentPos().getRange() != null) {
+ int line = comment.getCommentPos().getRange().getBeginLine();
List<CommentInfo> commentInfosAtLine = commentInfos.get(line);
if (commentInfosAtLine == null) {
commentInfosAtLine = new ArrayList<>();
@@ -937,7 +938,7 @@ public class SourceViewPanel extends BlobViewPanel {
}
CommentInfo commentInfo = new CommentInfo();
commentInfo.id = comment.getId();
- commentInfo.mark = comment.getMark();
+ commentInfo.mark = comment.getCommentPos().getRange();
commentInfo.title = comment.getTitle();
commentInfosAtLine.add(commentInfo);
}
@@ -1000,7 +1001,7 @@ public class SourceViewPanel extends BlobViewPanel {
String title;
- Mark mark;
+ TextRange mark;
}
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/fileedit/FileEditPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/fileedit/FileEditPanel.java
index 5a5b891c2d..f9b4888708 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/fileedit/FileEditPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/fileedit/FileEditPanel.java
@@ -40,7 +40,7 @@ import com.pmease.commons.wicket.component.ViewStateAwareAjaxLink;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.web.component.depotfile.editsave.EditSavePanel;
import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;
import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;
@@ -63,7 +63,7 @@ public abstract class FileEditPanel extends Panel {
private final ObjectId prevCommitId;
- private final Mark mark;
+ private final TextRange mark;
private AbstractDefaultAjaxBehavior previewBehavior;
@@ -73,7 +73,7 @@ public abstract class FileEditPanel extends Panel {
public FileEditPanel(String id, IModel<Depot> depotModel, String refName,
@Nullable String oldPath, String content, ObjectId prevCommitId,
- @Nullable Mark mark) {
+ @Nullable TextRange mark) {
super(id);
this.depotModel = depotModel;
this.refName = refName;
@@ -250,7 +250,7 @@ public abstract class FileEditPanel extends Panel {
getMarkupId(), getNewPathParam()));
}
- private String getJson(Mark mark) {
+ private String getJson(TextRange mark) {
try {
return GitPlex.getInstance(ObjectMapper.class).writeValueAsString(mark);
} catch (JsonProcessingException e) {
@@ -258,7 +258,7 @@ public abstract class FileEditPanel extends Panel {
}
}
- public void mark(AjaxRequestTarget target, Mark mark) {
+ public void mark(AjaxRequestTarget target, TextRange mark) {
String script = String.format("gitplex.fileedit.mark('%s', %s);",
getMarkupId(), getJson(mark));
target.appendJavaScript(script);
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.java
index 423900413a..1dd8ad6abb 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
@@ -22,12 +22,12 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.web.Constants;
import com.pmease.gitplex.web.component.diff.DiffRenderer;
import com.pmease.gitplex.web.component.diff.blob.text.TextDiffPanel;
import com.pmease.gitplex.web.component.diff.difftitle.BlobDiffTitle;
-import com.pmease.gitplex.web.component.diff.revision.BlobMarkSupport;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
+import com.pmease.gitplex.web.component.diff.revision.BlobCommentSupport;
import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;
@SuppressWarnings("serial")
@@ -45,11 +45,11 @@ public class BlobDiffPanel extends Panel implements SourceAware {
private final DiffViewMode diffMode;
- private final BlobMarkSupport markSupport;
+ private final BlobCommentSupport markSupport;
public BlobDiffPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,
BlobChange change, DiffViewMode diffMode, @Nullable IModel<Boolean> blameModel,
- @Nullable BlobMarkSupport markSupport) {
+ @Nullable BlobCommentSupport markSupport) {
super(id);
this.depotModel = depotModel;
@@ -184,7 +184,7 @@ public class BlobDiffPanel extends Panel implements SourceAware {
}
@Override
- public void mark(AjaxRequestTarget target, DiffMark mark) {
+ public void mark(AjaxRequestTarget target, CommentPos mark) {
Component content = get(CONTENT_ID);
if (content instanceof SourceAware) {
SourceAware sourceAware = (SourceAware) content;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/SourceAware.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/SourceAware.java
index 7a2c432a24..925b30d9b1 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/SourceAware.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/SourceAware.java
@@ -5,7 +5,7 @@ import javax.annotation.Nullable;
import org.apache.wicket.ajax.AjaxRequestTarget;
import com.pmease.gitplex.core.entity.CodeComment;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
+import com.pmease.gitplex.core.entity.component.CommentPos;
public interface SourceAware {
@@ -15,7 +15,7 @@ public interface SourceAware {
void onCommentAdded(AjaxRequestTarget target, CodeComment comment);
- void mark(AjaxRequestTarget target, @Nullable DiffMark mark);
+ void mark(AjaxRequestTarget target, @Nullable CommentPos mark);
void onUnblame(AjaxRequestTarget target);
}
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.java
index 0e9ca3c253..83c322f061 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
@@ -60,7 +60,8 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.CommentPos;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.search.hit.QueryHit;
@@ -70,8 +71,7 @@ import com.pmease.gitplex.web.component.diff.blob.SourceAware;
import com.pmease.gitplex.web.component.diff.blob.text.MarkAwareDiffBlock.Type;
import com.pmease.gitplex.web.component.diff.diffstat.DiffStatBar;
import com.pmease.gitplex.web.component.diff.difftitle.BlobDiffTitle;
-import com.pmease.gitplex.web.component.diff.revision.BlobMarkSupport;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
+import com.pmease.gitplex.web.component.diff.revision.BlobCommentSupport;
import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;
import com.pmease.gitplex.web.component.symboltooltip.SymbolTooltipPanel;
import com.pmease.gitplex.web.page.depot.commit.CommitDetailPage;
@@ -95,7 +95,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
private final IModel<Boolean> blameModel;
- private final BlobMarkSupport markSupport;
+ private final BlobCommentSupport markSupport;
private Component symbolTooltip;
@@ -107,7 +107,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
public TextDiffPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,
BlobChange change, DiffViewMode diffMode, @Nullable IModel<Boolean> blameModel,
- @Nullable BlobMarkSupport markSupport) {
+ @Nullable BlobCommentSupport markSupport) {
super(id);
this.depotModel = depotModel;
@@ -122,7 +122,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
}
}
- private String getJson(DiffMark mark) {
+ private String getJson(CommentPos mark) {
try {
MarkInfo markInfo = new MarkInfo(mark, getOldCommit().name());
return GitPlex.getInstance(ObjectMapper.class).writeValueAsString(markInfo);
@@ -269,7 +269,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
String jsonOfPosition = String.format("{left: %d, top: %d}",
params.getParameterValue("param1").toInt(),
params.getParameterValue("param2").toInt());
- DiffMark mark = getMark(params, "param3", "param4", "param5", "param6", "param7");
+ CommentPos mark = getMark(params, "param3", "param4", "param5", "param6", "param7");
script = String.format("gitplex.textdiff.openSelectionPopover('%s', %s, %s, '%s', %s);",
getMarkupId(), jsonOfPosition, getJson(mark), markSupport.getMarkUrl(mark),
SecurityUtils.getAccount()!=null);
@@ -324,7 +324,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
setOutputMarkupId(true);
}
- private DiffMark getMark(IRequestParameters params, String leftSideParam,
+ private CommentPos getMark(IRequestParameters params, String leftSideParam,
String beginLineParam, String beginCharParam,
String endLineParam, String endCharParam) {
boolean leftSide = params.getParameterValue(leftSideParam).toBoolean();
@@ -333,7 +333,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
int endLine = params.getParameterValue(endLineParam).toInt();
int endChar = params.getParameterValue(endCharParam).toInt();
String commit = leftSide?getOldCommit().name():getNewCommit().name();
- return new DiffMark(commit, change.getPath(), beginLine, beginChar, endLine, endChar);
+ return new CommentPos(commit, change.getPath(), new TextRange(beginLine, beginChar, endLine, endChar));
}
private void appendEquals(StringBuilder builder, int index, int lastContextSize, int contextSize) {
@@ -406,8 +406,8 @@ public class TextDiffPanel extends Panel implements SourceAware {
Map<Integer, List<CommentInfo>> oldCommentInfos = new HashMap<>();
Map<Integer, List<CommentInfo>> newCommentInfos = new HashMap<>();
for (CodeComment comment: markSupport.getComments()) {
- if (comment.getMark() != null) {
- int line = comment.getMark().getBeginLine();
+ if (comment.getCommentPos().getRange() != null) {
+ int line = comment.getCommentPos().getRange().getBeginLine();
List<CommentInfo> commentInfosAtLine;
CommentInfo commentInfo = new CommentInfo();
commentInfo.id = comment.getId();
@@ -444,7 +444,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
throw new RuntimeException(e);
}
- DiffMark mark = markSupport.getMark();
+ CommentPos mark = markSupport.getMark();
if (mark != null) {
jsonOfMark = getJson(mark);
} else {
@@ -907,18 +907,18 @@ public class TextDiffPanel extends Panel implements SourceAware {
List<Range> oldRanges = new ArrayList<>();
List<Range> newRanges = new ArrayList<>();
if (markSupport != null) {
- List<DiffMark> marks = new ArrayList<>();
- DiffMark mark = markSupport.getMark();
+ List<CommentPos> marks = new ArrayList<>();
+ CommentPos mark = markSupport.getMark();
if (mark != null) {
marks.add(mark);
}
String oldCommitHash = getOldCommit().name();
for (CodeComment comment: markSupport.getComments()) {
- mark = new DiffMark(comment);
+ mark = comment.getCommentPos();
marks.add(mark);
}
- for (DiffMark each: marks) {
- Range range = new Range(each.beginLine, each.endLine+1);
+ for (CommentPos each: marks) {
+ Range range = new Range(each.getRange().beginLine, each.getRange().endLine+1);
if (each.getCommit().equals(oldCommitHash)) {
oldRanges.add(range);
} else {
@@ -1025,7 +1025,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
}
@Override
- public void mark(AjaxRequestTarget target, DiffMark mark) {
+ public void mark(AjaxRequestTarget target, CommentPos mark) {
String script;
if (mark != null) {
script = String.format(""
@@ -1060,7 +1060,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
}
@SuppressWarnings("unused")
- private static class MarkInfo extends Mark {
+ private static class MarkInfo extends TextRange {
String path;
@@ -1071,13 +1071,13 @@ public class TextDiffPanel extends Panel implements SourceAware {
}
public MarkInfo(CodeComment comment, String oldCommitHash) {
- super(comment.getMark());
- path = comment.getPath();
- leftSide = comment.getCommit().equals(oldCommitHash);
+ super(comment.getCommentPos().getRange());
+ path = comment.getCommentPos().getPath();
+ leftSide = comment.getCommentPos().getCommit().equals(oldCommitHash);
}
- public MarkInfo(DiffMark mark, String oldCommitHash) {
- super(mark);
+ public MarkInfo(CommentPos mark, String oldCommitHash) {
+ super(mark.getRange());
path = mark.getPath();
leftSide = mark.getCommit().equals(oldCommitHash);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/BlobMarkSupport.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/BlobCommentSupport.java
similarity index 65%
rename from gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/BlobMarkSupport.java
rename to gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/BlobCommentSupport.java
index 5dbfecfc4b..8bfe02fa60 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/BlobMarkSupport.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/BlobCommentSupport.java
@@ -9,20 +9,21 @@ import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import com.pmease.gitplex.core.entity.CodeComment;
+import com.pmease.gitplex.core.entity.component.CommentPos;
-public interface BlobMarkSupport extends Serializable {
+public interface BlobCommentSupport extends Serializable {
Collection<CodeComment> getComments();
- @Nullable DiffMark getMark();
+ @Nullable CommentPos getMark();
- String getMarkUrl(DiffMark mark);
+ String getMarkUrl(CommentPos mark);
@Nullable CodeComment getOpenComment();
void onOpenComment(AjaxRequestTarget target, CodeComment comment);
- void onAddComment(AjaxRequestTarget target, DiffMark mark);
+ void onAddComment(AjaxRequestTarget target, CommentPos commentPos);
Component getDirtyContainer();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/MarkSupport.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/CommentSupport.java
similarity index 56%
rename from gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/MarkSupport.java
rename to gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/CommentSupport.java
index 421725943d..7e4292915a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/MarkSupport.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/CommentSupport.java
@@ -7,14 +7,15 @@ import javax.annotation.Nullable;
import org.apache.wicket.ajax.AjaxRequestTarget;
import com.pmease.gitplex.core.entity.CodeComment;
+import com.pmease.gitplex.core.entity.component.CommentPos;
-public interface MarkSupport extends Serializable {
+public interface CommentSupport extends Serializable {
- @Nullable DiffMark getMark();
+ @Nullable CommentPos getMark();
- void onMark(AjaxRequestTarget target, DiffMark mark);
+ void onMark(AjaxRequestTarget target, CommentPos mark);
- String getMarkUrl(DiffMark mark);
+ String getMarkUrl(CommentPos mark);
String getCommentUrl(CodeComment comment);
@@ -22,6 +23,6 @@ public interface MarkSupport extends Serializable {
void onCommentOpened(AjaxRequestTarget target, @Nullable CodeComment comment);
- void onAddComment(AjaxRequestTarget target, DiffMark mark);
+ void onAddComment(AjaxRequestTarget target, CommentPos commentPos);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffMark.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffMark.java
deleted file mode 100644
index 0ad059016a..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/DiffMark.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.pmease.gitplex.web.component.diff.revision;
-
-import javax.annotation.Nullable;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
-import com.pmease.gitplex.core.entity.CodeComment;
-import com.pmease.gitplex.core.entity.component.Mark;
-
-public class DiffMark extends Mark {
-
- private static final long serialVersionUID = 1L;
-
- private final String commit;
-
- private final String path;
-
- public DiffMark(String commit, String path, int beginLine, int beginChar,
- int endLine, int endChar) {
- super(beginLine, beginChar, endLine, endChar);
- this.commit = commit;
- this.path = path;
- }
-
- public DiffMark(String commit, String path, Mark mark) {
- super(mark);
- this.commit = commit;
- this.path = path;
- }
-
- public DiffMark(CodeComment comment) {
- super(comment.getMark());
- commit = comment.getCommit();
- path = comment.getPath();
- }
-
- public String getCommit() {
- return commit;
- }
-
- public String getPath() {
- return path;
- }
-
- public DiffMark(String str) {
- super(str.substring(getMarkIndex(str)+1));
- String tempStr = str.substring(0, getMarkIndex(str));
- commit = StringUtils.substringBefore(tempStr, "-");
- path = StringUtils.substringAfter(tempStr, "-");
- }
-
- private static int getMarkIndex(String str) {
- return str.substring(0, str.lastIndexOf('-')).lastIndexOf('-');
- }
-
- @Override
- public String toString() {
- return commit + "-" + path + "-" + super.toString();
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof DiffMark))
- return false;
- if (this == other)
- return true;
- DiffMark otherMark = (DiffMark) other;
- return new EqualsBuilder()
- .append(commit, otherMark.commit)
- .append(path, otherMark.path)
- .append(beginLine, otherMark.beginLine)
- .append(beginChar, otherMark.beginChar)
- .append(endLine, otherMark.endLine)
- .append(endChar, otherMark.endChar)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37)
- .append(commit)
- .append(path)
- .append(beginLine)
- .append(beginChar)
- .append(endLine)
- .append(endChar)
- .toHashCode();
- }
-
- public static DiffMark of(@Nullable String markStr) {
- if (markStr != null)
- return new DiffMark(markStr);
- else
- return null;
- }
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
index 0a1a9edfce..4f1e73a361 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
@@ -14,9 +14,9 @@
<td class="path-filter">
<form wicket:id="pathFilter">
<div class="input-group">
- <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="false" placeholder="Filter by path pattern" type="text"></input>
+ <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="false" placeholder="Search by path pattern" type="text"></input>
<span class="input-group-btn">
- <button wicket:id="submit" title="Filter" class="btn btn-default" type="submit"><i class="fa fa-filter"></i></button>
+ <button wicket:id="submit" title="Filter" class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
@@ -24,8 +24,13 @@
</tr>
</table>
<div wicket:id="body" class="body">
- <div class="title">
- Total <a wicket:id="totalFiles"></a>
+ <div class="info clearfix">
+ <span class="title pull-left">
+ Total <a wicket:id="totalFiles" class="total-files"></a>
+ </span>
+ <span class="comment pull-right">
+ <a wicket:id="addComment" title="Comment on the whole comparison">Add comment</a>
+ </span>
</div>
<div wicket:id="tooManyFiles" class="alert alert-warning">Sorry we are unable to display all files as there are too many</div>
<ul wicket:id="diffStats" class="diff-stats list-unstyled">
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.java
index 99b23af4da..1c7f6136d1 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
@@ -84,9 +84,9 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.core.entity.component.CompareContext;
import com.pmease.gitplex.core.entity.component.DepotAndRevision;
-import com.pmease.gitplex.core.entity.component.Mark;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.web.Constants;
@@ -128,7 +128,7 @@ public class RevisionDiffPanel extends Panel {
private final IModel<String> blameModel;
- private final MarkSupport markSupport;
+ private final CommentSupport commentSupport;
private final IModel<String> pathFilterModel;
@@ -168,9 +168,10 @@ public class RevisionDiffPanel extends Panel {
Set<String> markedPaths = new HashSet<>();
for (CodeComment comment: commentsModel.getObject()) {
- if (!changedPaths.contains(comment.getPath()) && !markedPaths.contains(comment.getPath())) {
- BlobIdent oldBlobIdent = new BlobIdent(oldRev, comment.getPath(), FileMode.TYPE_FILE);
- BlobIdent newBlobIdent = new BlobIdent(newRev, comment.getPath(), FileMode.TYPE_FILE);
+ if (!changedPaths.contains(comment.getCommentPos().getPath())
+ && !markedPaths.contains(comment.getCommentPos().getPath())) {
+ BlobIdent oldBlobIdent = new BlobIdent(oldRev, comment.getCommentPos().getPath(), FileMode.TYPE_FILE);
+ BlobIdent newBlobIdent = new BlobIdent(newRev, comment.getCommentPos().getPath(), FileMode.TYPE_FILE);
allChanges.add(new BlobChange(null, oldBlobIdent, newBlobIdent, whitespaceOptionModel.getObject()) {
@Override
@@ -180,10 +181,10 @@ public class RevisionDiffPanel extends Panel {
});
}
- markedPaths.add(comment.getPath());
+ markedPaths.add(comment.getCommentPos().getPath());
}
- DiffMark mark = getMark();
+ CommentPos mark = getMark();
if (mark != null && !changedPaths.contains(mark.getPath()) && !markedPaths.contains(mark.getPath())) {
BlobIdent oldBlobIdent = new BlobIdent(oldRev, mark.getPath(), FileMode.TYPE_FILE);
BlobIdent newBlobIdent = new BlobIdent(newRev, mark.getPath(), FileMode.TYPE_FILE);
@@ -347,7 +348,7 @@ public class RevisionDiffPanel extends Panel {
@Override
protected Collection<CodeComment> load() {
- if (markSupport != null) {
+ if (commentSupport != null) {
return GitPlex.getInstance(CodeCommentManager.class).query(
depotModel.getObject(), getOldCommit(), getNewCommit());
} else {
@@ -363,7 +364,7 @@ public class RevisionDiffPanel extends Panel {
public RevisionDiffPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,
String oldRev, String newRev, IModel<String> pathFilterModel, IModel<WhitespaceOption> whitespaceOptionModel,
- @Nullable IModel<String> blameModel, @Nullable MarkSupport markSupport) {
+ @Nullable IModel<String> blameModel, @Nullable CommentSupport markSupport) {
super(id);
this.depotModel = depotModel;
@@ -397,7 +398,7 @@ public class RevisionDiffPanel extends Panel {
};
this.whitespaceOptionModel = whitespaceOptionModel;
- this.markSupport = markSupport;
+ this.commentSupport = markSupport;
WebRequest request = (WebRequest) RequestCycle.get().getRequest();
Cookie cookie = request.getCookie(COOKIE_VIEW_MODE);
@@ -525,7 +526,7 @@ public class RevisionDiffPanel extends Panel {
}
}
for (CodeComment comment: commentsModel.getObject()) {
- setOfInvolvedPaths.add(comment.getPath());
+ setOfInvolvedPaths.add(comment.getCommentPos().getPath());
}
List<String> listOfInvolvedPaths = new ArrayList<>(setOfInvolvedPaths);
@@ -599,6 +600,15 @@ public class RevisionDiffPanel extends Panel {
}
}));
+
+ body.add(new AjaxLink<Void>("addComment") {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+
+ }
+
+ });
body.add(new WebMarkupContainer("tooManyFiles") {
@@ -653,7 +663,7 @@ public class RevisionDiffPanel extends Panel {
boolean hasComments = false;
for (CodeComment comment: commentsModel.getObject()) {
- if (change.getPaths().contains(comment.getPath())) {
+ if (change.getPaths().contains(comment.getCommentPos().getPath())) {
hasComments = true;
break;
}
@@ -695,13 +705,13 @@ public class RevisionDiffPanel extends Panel {
protected void populateItem(ListItem<BlobChange> item) {
BlobChange change = item.getModelObject();
item.setMarkupId("diff-" + change.getPath());
- if (markSupport != null) {
+ if (commentSupport != null) {
item.add(new BlobDiffPanel(DIFF_ID, depotModel, requestModel, change, diffMode,
- getBlobBlameModel(change), new BlobMarkSupport() {
+ getBlobBlameModel(change), new BlobCommentSupport() {
@Override
- public DiffMark getMark() {
- DiffMark mark = RevisionDiffPanel.this.getMark();
+ public CommentPos getMark() {
+ CommentPos mark = RevisionDiffPanel.this.getMark();
if (mark != null && change.getPaths().contains(mark.getPath()))
return mark;
else
@@ -709,14 +719,14 @@ public class RevisionDiffPanel extends Panel {
}
@Override
- public String getMarkUrl(DiffMark mark) {
- return markSupport.getMarkUrl(mark);
+ public String getMarkUrl(CommentPos mark) {
+ return commentSupport.getMarkUrl(mark);
}
@Override
public CodeComment getOpenComment() {
CodeComment comment = RevisionDiffPanel.this.getOpenComment();
- if (comment != null && change.getPaths().contains(comment.getPath()))
+ if (comment != null && change.getPaths().contains(comment.getCommentPos().getPath()))
return comment;
else
return null;
@@ -744,7 +754,7 @@ public class RevisionDiffPanel extends Panel {
@Override
protected CompareContext getCompareContext() {
- return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommit());
+ return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommentPos().getCommit());
}
@Override
@@ -765,24 +775,24 @@ public class RevisionDiffPanel extends Panel {
CodeComment prevComment = RevisionDiffPanel.this.getOpenComment();
if (prevComment != null) {
- SourceAware sourceAware = getSourceAware(prevComment.getPath());
+ SourceAware sourceAware = getSourceAware(prevComment.getCommentPos().getPath());
if (sourceAware != null)
sourceAware.onCommentClosed(target, prevComment);
}
- DiffMark prevMark = RevisionDiffPanel.this.getMark();
+ CommentPos prevMark = RevisionDiffPanel.this.getMark();
if (prevMark != null) {
SourceAware sourceAware = getSourceAware(prevMark.getPath());
if (sourceAware != null)
sourceAware.mark(target, null);
}
- markSupport.onCommentOpened(target, comment);
+ commentSupport.onCommentOpened(target, comment);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
}
@Override
- public void onAddComment(AjaxRequestTarget target, DiffMark mark) {
+ public void onAddComment(AjaxRequestTarget target, CommentPos mark) {
commentContainer.setDefaultModelObject(mark);
Fragment fragment = new Fragment(BODY_ID, "newCommentFrag", RevisionDiffPanel.this);
@@ -847,11 +857,8 @@ public class RevisionDiffPanel extends Panel {
comment.setUUID(uuid);
comment.setDepot(depotModel.getObject());
comment.setUser(SecurityUtils.getAccount());
- comment.setCommit(mark.getCommit());
- comment.setPath(mark.getPath());
- comment.setMark(new Mark(mark.getBeginLine(), mark.getBeginChar(),
- mark.getEndLine(), mark.getEndChar()));
- comment.setCompareContext(getCompareContext(comment.getCommit()));
+ comment.setCommentPos(mark);
+ comment.setCompareContext(getCompareContext(comment.getCommentPos().getCommit()));
comment.setTitle(titleInput.getModelObject());
comment.setContent(contentInput.getModelObject());
GitPlex.getInstance(CodeCommentManager.class).save(comment);
@@ -875,7 +882,7 @@ public class RevisionDiffPanel extends Panel {
@Override
protected CompareContext getCompareContext() {
- return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommit());
+ return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommentPos().getCommit());
}
@Override
@@ -892,11 +899,11 @@ public class RevisionDiffPanel extends Panel {
commentContainer.replace(commentPanel);
target.add(commentContainer);
- SourceAware sourceAware = getSourceAware(comment.getPath());
+ SourceAware sourceAware = getSourceAware(comment.getCommentPos().getPath());
if (sourceAware != null)
sourceAware.onCommentAdded(target, comment);
- markSupport.onCommentOpened(target, comment);
+ commentSupport.onCommentOpened(target, comment);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
}
@@ -907,7 +914,7 @@ public class RevisionDiffPanel extends Panel {
commentContainer.setVisible(true);
target.add(commentContainer);
- DiffMark prevMark = RevisionDiffPanel.this.getMark();
+ CommentPos prevMark = RevisionDiffPanel.this.getMark();
if (prevMark != null) {
SourceAware sourceAware = getSourceAware(prevMark.getPath());
if (sourceAware != null)
@@ -916,11 +923,11 @@ public class RevisionDiffPanel extends Panel {
CodeComment prevComment = RevisionDiffPanel.this.getOpenComment();
if (prevComment != null) {
- SourceAware sourceAware = getSourceAware(prevComment.getPath());
+ SourceAware sourceAware = getSourceAware(prevComment.getCommentPos().getPath());
if (sourceAware != null)
sourceAware.onCommentClosed(target, prevComment);
}
- markSupport.onAddComment(target, mark);
+ commentSupport.onAddComment(target, mark);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
}
@@ -928,7 +935,7 @@ public class RevisionDiffPanel extends Panel {
public Collection<CodeComment> getComments() {
Collection<CodeComment> comments = new ArrayList<>();
for (CodeComment comment: commentsModel.getObject()) {
- if (change.getPaths().contains(comment.getPath())) {
+ if (change.getPaths().contains(comment.getCommentPos().getPath())) {
comments.add(comment);
}
}
@@ -952,6 +959,145 @@ public class RevisionDiffPanel extends Panel {
setOutputMarkupId(true);
}
+ private void onAddComment(AjaxRequestTarget target, CommentPos mark) {
+ commentContainer.setDefaultModelObject(mark);
+
+ Fragment fragment = new Fragment(BODY_ID, "newCommentFrag", RevisionDiffPanel.this);
+ fragment.setOutputMarkupId(true);
+
+ Form<?> form = new Form<Void>("form");
+
+ String uuid = UUID.randomUUID().toString();
+
+ TextField<String> titleInput = new TextField<String>("title", Model.of(""));
+ titleInput.setRequired(true);
+ form.add(titleInput);
+ CommentInput contentInput;
+ form.add(contentInput = new CommentInput("content", Model.of("")) {
+
+ @Override
+ protected DepotAttachmentSupport getAttachmentSupport() {
+ return new DepotAttachmentSupport(depotModel.getObject(), uuid);
+ }
+
+ @Override
+ protected Depot getDepot() {
+ return depotModel.getObject();
+ }
+
+ });
+ contentInput.setRequired(true);
+
+ NotificationPanel feedback = new NotificationPanel("feedback", form);
+ feedback.setOutputMarkupPlaceholderTag(true);
+ form.add(feedback);
+
+ form.add(new AjaxLink<Void>("cancel") {
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(form));
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ clearComment(target);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
+
+ });
+
+ form.add(new AjaxButton("save") {
+
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+ super.onError(target, form);
+ target.add(feedback);
+ }
+
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ super.onSubmit(target, form);
+
+ CodeComment comment = new CodeComment();
+ comment.setUUID(uuid);
+ comment.setDepot(depotModel.getObject());
+ comment.setUser(SecurityUtils.getAccount());
+ comment.setCommentPos(mark);
+ comment.setCompareContext(getCompareContext(comment.getCommentPos().getCommit()));
+ comment.setTitle(titleInput.getModelObject());
+ comment.setContent(contentInput.getModelObject());
+ GitPlex.getInstance(CodeCommentManager.class).save(comment);
+
+ Long commentId = comment.getId();
+ IModel<CodeComment> commentModel = new LoadableDetachableModel<CodeComment>() {
+
+ @Override
+ protected CodeComment load() {
+ return GitPlex.getInstance(CodeCommentManager.class).load(commentId);
+ }
+
+ };
+ CodeCommentPanel commentPanel = new CodeCommentPanel(fragment.getId(), commentModel) {
+
+ @Override
+ protected void onCommentDeleted(AjaxRequestTarget target) {
+ CodeComment comment = commentModel.getObject();
+ RevisionDiffPanel.this.onCommentDeleted(target, comment);
+ }
+
+ @Override
+ protected CompareContext getCompareContext() {
+ return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommentPos().getCommit());
+ }
+
+ @Override
+ protected void onSaveComment(AjaxRequestTarget target) {
+ target.add(commentContainer.get("head"));
+ }
+
+ @Override
+ protected PullRequest getPullRequest() {
+ return requestModel.getObject();
+ }
+
+ };
+ commentContainer.replace(commentPanel);
+ target.add(commentContainer);
+
+ SourceAware sourceAware = getSourceAware(comment.getCommentPos().getPath());
+ if (sourceAware != null)
+ sourceAware.onCommentAdded(target, comment);
+
+ commentSupport.onCommentOpened(target, comment);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
+
+ });
+ fragment.add(form);
+
+ commentContainer.replace(fragment);
+ commentContainer.setVisible(true);
+ target.add(commentContainer);
+
+ CommentPos prevMark = RevisionDiffPanel.this.getMark();
+ if (prevMark != null) {
+ SourceAware sourceAware = getSourceAware(prevMark.getPath());
+ if (sourceAware != null)
+ sourceAware.mark(target, null);
+ }
+
+ CodeComment prevComment = RevisionDiffPanel.this.getOpenComment();
+ if (prevComment != null) {
+ SourceAware sourceAware = getSourceAware(prevComment.getCommentPos().getPath());
+ if (sourceAware != null)
+ sourceAware.onCommentClosed(target, prevComment);
+ }
+ commentSupport.onAddComment(target, mark);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
+
private @Nullable IModel<Boolean> getBlobBlameModel(BlobChange change) {
if (blameModel != null) {
return new IModel<Boolean>() {
@@ -980,7 +1126,7 @@ public class RevisionDiffPanel extends Panel {
}
private WebMarkupContainer newCommentContainer() {
- WebMarkupContainer commentContainer = new WebMarkupContainer("comment", Model.of((DiffMark)null)) {
+ WebMarkupContainer commentContainer = new WebMarkupContainer("comment", Model.of((CommentPos)null)) {
@Override
public void renderHead(IHeaderResponse response) {
@@ -1049,16 +1195,16 @@ public class RevisionDiffPanel extends Panel {
RequestChangesPage.State state = new RequestChangesPage.State();
CodeComment comment = getOpenComment();
state.commentId = comment.getId();
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
int index = commitsModel.getObject().stream().map(BriefCommit::getHash).collect(Collectors.toList())
- .indexOf(comment.getCommit());
+ .indexOf(comment.getCommentPos().getCommit());
int compareIndex = commitsModel.getObject().indexOf(commit);
if (index < compareIndex) {
- state.oldCommit = comment.getCommit();
+ state.oldCommit = comment.getCommentPos().getCommit();
state.newCommit = commit.getHash();
} else {
state.oldCommit = commit.getHash();
- state.newCommit = comment.getCommit();
+ state.newCommit = comment.getCommentPos().getCommit();
}
PageParameters params = RequestChangesPage.paramsOf(requestModel.getObject(), state);
setResponsePage(RequestChangesPage.class, params);
@@ -1067,7 +1213,7 @@ public class RevisionDiffPanel extends Panel {
};
link.add(new Label("hash", GitUtils.abbreviateSHA(commit.getHash())));
link.add(new Label("subject", commit.getSubject()));
- if (commit.getHash().equals(getOpenComment().getCommit())) {
+ if (commit.getHash().equals(getOpenComment().getCommentPos().getCommit())) {
link.setEnabled(false);
link.add(AttributeAppender.append("class", "commented"));
link.add(new WebMarkupContainer("commented"));
@@ -1094,9 +1240,9 @@ public class RevisionDiffPanel extends Panel {
RevisionComparePage.State state = new RevisionComparePage.State();
CodeComment comment = getOpenComment();
state.commentId = comment.getId();
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.compareWithMergeBase = false;
- state.leftSide = new DepotAndRevision(comment.getDepot(), comment.getCommit());
+ state.leftSide = new DepotAndRevision(comment.getDepot(), comment.getCommentPos().getCommit());
state.rightSide = new DepotAndRevision(comment.getDepot(), revision);
state.tabPanel = RevisionComparePage.TabPanel.CHANGES;
PageParameters params = RevisionComparePage.paramsOf(comment.getDepot(), state);
@@ -1120,16 +1266,16 @@ public class RevisionDiffPanel extends Panel {
@Override
public void onClick(AjaxRequestTarget target) {
CodeComment comment = getOpenComment();
- DiffMark mark;
+ CommentPos mark;
if (comment != null) {
- mark = new DiffMark(comment);
+ mark = comment.getCommentPos();
} else {
- mark = (DiffMark)commentContainer.getDefaultModelObject();
+ mark = (CommentPos)commentContainer.getDefaultModelObject();
}
SourceAware sourceAware = getSourceAware(mark.getPath());
if (sourceAware != null)
sourceAware.mark(target, mark);
- markSupport.onMark(target, mark);
+ commentSupport.onMark(target, mark);
target.appendJavaScript(String.format("$('#%s').blur();", getMarkupId()));
}
@@ -1142,7 +1288,7 @@ public class RevisionDiffPanel extends Panel {
@Override
protected String load() {
if (getOpenComment() != null) {
- return markSupport.getCommentUrl(getOpenComment());
+ return commentSupport.getCommentUrl(getOpenComment());
} else {
return "";
}
@@ -1173,14 +1319,14 @@ public class RevisionDiffPanel extends Panel {
clearComment(target);
CodeComment comment = getOpenComment();
if (comment != null) {
- SourceAware sourceAware = getSourceAware(comment.getPath());
+ SourceAware sourceAware = getSourceAware(comment.getCommentPos().getPath());
if (sourceAware != null)
sourceAware.onCommentClosed(target, comment);
- markSupport.onCommentOpened(target, null);
+ commentSupport.onCommentOpened(target, null);
}
target.appendJavaScript("gitplex.revisionDiff.reposition();");
- DiffMark mark = getMark();
+ CommentPos mark = getMark();
if (mark != null) {
SourceAware sourceAware = getSourceAware(mark.getPath());
if (sourceAware != null) {
@@ -1246,7 +1392,7 @@ public class RevisionDiffPanel extends Panel {
CodeComment comment = getOpenComment();
if (comment != null) {
for (BlobChange change: changesAndCountModel.getObject().getChanges()) {
- if (change.getPaths().contains(comment.getPath())) {
+ if (change.getPaths().contains(comment.getCommentPos().getPath())) {
locatable = true;
break;
}
@@ -1272,7 +1418,7 @@ public class RevisionDiffPanel extends Panel {
@Override
protected CompareContext getCompareContext() {
- return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommit());
+ return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommentPos().getCommit());
}
@Override
@@ -1305,10 +1451,10 @@ public class RevisionDiffPanel extends Panel {
@Nullable
private CodeComment getOpenComment() {
- if (markSupport != null) {
- CodeComment comment = markSupport.getOpenComment();
+ if (commentSupport != null) {
+ CodeComment comment = commentSupport.getOpenComment();
if (comment != null) {
- String commit = comment.getCommit();
+ String commit = comment.getCommentPos().getCommit();
String oldCommitHash = getOldCommit().name();
String newCommitHash = getNewCommit().name();
if (commit.equals(oldCommitHash) || commit.equals(newCommitHash))
@@ -1319,9 +1465,9 @@ public class RevisionDiffPanel extends Panel {
}
@Nullable
- private DiffMark getMark() {
- if (markSupport != null) {
- DiffMark mark = markSupport.getMark();
+ private CommentPos getMark() {
+ if (commentSupport != null) {
+ CommentPos mark = commentSupport.getMark();
if (mark != null) {
String commit = mark.getCommit();
String oldCommitHash = getOldCommit().name();
@@ -1355,12 +1501,12 @@ public class RevisionDiffPanel extends Panel {
private void onCommentDeleted(AjaxRequestTarget target, CodeComment comment) {
clearComment(target);
- SourceAware sourceAware = getSourceAware(comment.getPath());
+ SourceAware sourceAware = getSourceAware(comment.getCommentPos().getPath());
if (sourceAware != null)
sourceAware.onCommentDeleted(target, comment);
- markSupport.onCommentOpened(target, null);
+ commentSupport.onCommentOpened(target, null);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
- DiffMark mark = getMark();
+ CommentPos mark = getMark();
if (mark != null) {
sourceAware = getSourceAware(mark.getPath());
if (sourceAware != null) {
@@ -1401,6 +1547,22 @@ public class RevisionDiffPanel extends Panel {
new CssResourceReference(RevisionDiffPanel.class, "revision-diff.css")));
}
+ private CompareContext getCompareContext(String commitHash) {
+ CompareContext compareContext = new CompareContext();
+ String oldCommitHash = getOldCommit().name();
+ String newCommitHash = getNewCommit().name();
+ if (commitHash.equals(oldCommitHash)) {
+ compareContext.setCompareCommit(newCommitHash);
+ compareContext.setLeftSide(false);
+ } else {
+ compareContext.setCompareCommit(oldCommitHash);
+ compareContext.setLeftSide(true);
+ }
+ compareContext.setPathFilter(pathFilterModel.getObject());
+ compareContext.setWhitespaceOption(whitespaceOptionModel.getObject());
+ return compareContext;
+ }
+
private static class ChangesAndCount {
private final List<BlobChange> changes;
@@ -1436,20 +1598,4 @@ public class RevisionDiffPanel extends Panel {
}
- private CompareContext getCompareContext(String commitHash) {
- CompareContext compareContext = new CompareContext();
- String oldCommitHash = getOldCommit().name();
- String newCommitHash = getNewCommit().name();
- if (commitHash.equals(oldCommitHash)) {
- compareContext.setCompareCommit(newCommitHash);
- compareContext.setLeftSide(false);
- } else {
- compareContext.setCompareCommit(oldCommitHash);
- compareContext.setLeftSide(true);
- }
- compareContext.setPathFilter(pathFilterModel.getObject());
- compareContext.setWhitespaceOption(whitespaceOptionModel.getObject());
- return compareContext;
- }
-
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
index 5b16a4f6b9..9db9489567 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
@@ -7,19 +7,22 @@
.revision-diff>.head td.whitespace-option {
width: 140px;
}
-.revision-diff>.body>.title {
- font-size: 16px;
+.revision-diff>.body>.info {
margin-bottom: 16px;
}
+.revision-diff>.body>.info>.title {
+ font-size: 16px;
+ margin-right: 16px;
+}
.revision-diff>.body>.alert {
margin-bottom: 16px;
}
-.revision-diff>.body>.title>a:after {
+.revision-diff>.body>.info>.title>a:after {
font-family: FontAwesome;
font-weight: bold;
content: "\f107";
}
-.revision-diff>.body>.title>a.expanded:after {
+.revision-diff>.body>.info>.title>a.expanded:after {
content: "\f106";
}
.revision-diff>.body>.diff-stats>.diff-stat {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js
index 1f3f85f373..8c2f32151c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js
@@ -3,7 +3,7 @@ gitplex.revisionDiff = {
var cookieName = "revisionDiff.showDiffStats";
var $body = $(".revision-diff>.body");
var $diffStats = $body.children(".diff-stats");
- var $diffStatsToggle = $body.find(">.title a");
+ var $diffStatsToggle = $body.find(">.info>.title a");
$diffStatsToggle.click(function() {
if ($diffStats.is(":visible")) {
$diffStats.hide();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java
index efae4f8bf9..ddfa210a30 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java
@@ -38,7 +38,7 @@ import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.SearchManager;
import com.pmease.gitplex.search.hit.QueryHit;
import com.pmease.gitplex.search.query.BlobQuery;
@@ -239,7 +239,7 @@ public abstract class SymbolTooltipPanel extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent.revision = revision;
state.blobIdent.path = hit.getBlobPath();
- state.mark = Mark.of(hit.getTokenPos());
+ state.mark = TextRange.of(hit.getTokenPos());
state.requestId = PullRequest.idOf(requestModel.getObject());
return DepotFilePage.paramsOf(depotModel.getObject(), state);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java
index 0436b2e50d..0c0b1d9082 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java
@@ -44,14 +44,14 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.manager.CommitInfoManager;
import com.pmease.gitplex.web.component.avatar.ContributorAvatars;
import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;
import com.pmease.gitplex.web.component.createbranch.CreateBranchLink;
import com.pmease.gitplex.web.component.createtag.CreateTagLink;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
-import com.pmease.gitplex.web.component.diff.revision.MarkSupport;
+import com.pmease.gitplex.web.component.diff.revision.CommentSupport;
import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;
import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;
import com.pmease.gitplex.web.page.depot.DepotPage;
@@ -60,7 +60,7 @@ import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
import com.pmease.gitplex.web.page.depot.tags.DepotTagsPage;
@SuppressWarnings("serial")
-public class CommitDetailPage extends DepotPage implements MarkSupport {
+public class CommitDetailPage extends DepotPage implements CommentSupport {
private static final String PARAM_REVISION = "revision";
@@ -453,7 +453,7 @@ public class CommitDetailPage extends DepotPage implements MarkSupport {
public String blameFile;
@Nullable
- public DiffMark mark;
+ public CommentPos mark;
public State() {
}
@@ -465,18 +465,18 @@ public class CommitDetailPage extends DepotPage implements MarkSupport {
pathFilter = params.get(PARAM_PATH_FILTER).toString();
blameFile = params.get(PARAM_BLAME_FILE).toString();
commentId = params.get(PARAM_COMMENT).toOptionalLong();
- mark = DiffMark.of(params.get(PARAM_MARK).toString());
+ mark = CommentPos.of(params.get(PARAM_MARK).toString());
}
}
@Override
- public DiffMark getMark() {
+ public CommentPos getMark() {
return state.mark;
}
@Override
- public String getMarkUrl(DiffMark mark) {
+ public String getMarkUrl(CommentPos mark) {
State markState = new State();
markState.mark = mark;
markState.whitespaceOption = state.whitespaceOption;
@@ -490,7 +490,7 @@ public class CommitDetailPage extends DepotPage implements MarkSupport {
public String getCommentUrl(CodeComment comment) {
State commentState = new State();
String compareWith = getCompareWith().name();
- commentState.mark = new DiffMark(comment);
+ commentState.mark = comment.getCommentPos();
commentState.commentId = comment.getId();
commentState.whitespaceOption = state.whitespaceOption;
commentState.compareWith = compareWith;
@@ -511,7 +511,7 @@ public class CommitDetailPage extends DepotPage implements MarkSupport {
public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {
if (comment != null) {
state.commentId = comment.getId();
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
} else {
state.commentId = null;
}
@@ -519,13 +519,13 @@ public class CommitDetailPage extends DepotPage implements MarkSupport {
}
@Override
- public void onMark(AjaxRequestTarget target, DiffMark mark) {
+ public void onMark(AjaxRequestTarget target, CommentPos mark) {
state.mark = mark;
pushState(target);
}
@Override
- public void onAddComment(AjaxRequestTarget target, DiffMark mark) {
+ public void onAddComment(AjaxRequestTarget target, CommentPos mark) {
state.commentId = null;
state.mark = mark;
pushState(target);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java
index a870584d49..2763a6dfff 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java
@@ -42,13 +42,13 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.core.entity.component.DepotAndBranch;
import com.pmease.gitplex.core.entity.component.DepotAndRevision;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.web.component.commitlist.CommitListPanel;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
-import com.pmease.gitplex.web.component.diff.revision.MarkSupport;
+import com.pmease.gitplex.web.component.diff.revision.CommentSupport;
import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;
import com.pmease.gitplex.web.component.revisionpicker.AffinalRevisionPicker;
import com.pmease.gitplex.web.page.depot.DepotPage;
@@ -59,7 +59,7 @@ import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.RequestDetail
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview.RequestOverviewPage;
@SuppressWarnings("serial")
-public class RevisionComparePage extends DepotPage implements MarkSupport {
+public class RevisionComparePage extends DepotPage implements CommentSupport {
public enum TabPanel {
COMMITS,
@@ -169,7 +169,7 @@ public class RevisionComparePage extends DepotPage implements MarkSupport {
state.whitespaceOption = WhitespaceOption.of(params.get(PARAM_WHITESPACE_OPTION).toString());
state.commentId = params.get(PARAM_COMMENT).toOptionalLong();
- state.mark = DiffMark.of(params.get(PARAM_MARK).toString());
+ state.mark = CommentPos.of(params.get(PARAM_MARK).toString());
state.tabPanel = TabPanel.of(params.get(PARAM_TAB).toString());
@@ -396,8 +396,9 @@ public class RevisionComparePage extends DepotPage implements MarkSupport {
@Override
public String getObject() {
- return requestModel.getObject().getId().toString();
+ return String.valueOf(requestModel.getObject().getNumber());
}
+
}));
add(new Link<Void>("link") {
@@ -621,7 +622,7 @@ public class RevisionComparePage extends DepotPage implements MarkSupport {
public Long commentId;
@Nullable
- public DiffMark mark;
+ public CommentPos mark;
public State() {
}
@@ -641,12 +642,12 @@ public class RevisionComparePage extends DepotPage implements MarkSupport {
}
@Override
- public DiffMark getMark() {
+ public CommentPos getMark() {
return state.mark;
}
@Override
- public String getMarkUrl(DiffMark mark) {
+ public String getMarkUrl(CommentPos mark) {
State markState = new State();
markState.leftSide = new DepotAndRevision(state.rightSide.getDepot(),
state.compareWithMergeBase?mergeBaseModel.getObject():leftCommitId.name());
@@ -665,7 +666,7 @@ public class RevisionComparePage extends DepotPage implements MarkSupport {
commentState.leftSide = new DepotAndRevision(state.rightSide.getDepot(),
state.compareWithMergeBase?mergeBaseModel.getObject():leftCommitId.name());
commentState.rightSide = new DepotAndRevision(state.rightSide.getDepot(), rightCommitId.name());
- commentState.mark = new DiffMark(comment);
+ commentState.mark = comment.getCommentPos();
commentState.commentId = comment.getId();
commentState.tabPanel = TabPanel.CHANGES;
commentState.pathFilter = state.pathFilter;
@@ -685,7 +686,7 @@ public class RevisionComparePage extends DepotPage implements MarkSupport {
@Override
public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {
if (comment != null) {
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
state.commentId = comment.getId();
} else {
state.commentId = null;
@@ -694,13 +695,13 @@ public class RevisionComparePage extends DepotPage implements MarkSupport {
}
@Override
- public void onMark(AjaxRequestTarget target, DiffMark mark) {
+ public void onMark(AjaxRequestTarget target, CommentPos mark) {
state.mark = mark;
pushState(target);
}
@Override
- public void onAddComment(AjaxRequestTarget target, DiffMark mark) {
+ public void onAddComment(AjaxRequestTarget target, CommentPos mark) {
state.commentId = null;
state.mark = mark;
pushState(target);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
index 2ec98abcfc..cbf1888757 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
@@ -61,7 +61,7 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.component.Mark;
+import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.core.listener.RefListener;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
@@ -147,7 +147,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
private ObjectId resolvedRevision;
- private Mark mark;
+ private TextRange mark;
private Mode mode;
@@ -207,7 +207,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
String modeStr = params.get(PARAM_MODE).toString();
if (modeStr != null)
mode = Mode.valueOf(modeStr.toUpperCase());
- mark = Mark.of(params.get(PARAM_MARK).toString());
+ mark = TextRange.of(params.get(PARAM_MARK).toString());
String commentIdStr = params.get(PARAM_COMMENT).toString();
if (commentIdStr != null)
@@ -825,18 +825,18 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
}
@Override
- public Mark getMark() {
+ public TextRange getMark() {
return mark;
}
@Override
- public void onMark(AjaxRequestTarget target, Mark mark) {
+ public void onMark(AjaxRequestTarget target, TextRange mark) {
this.mark = mark;
pushState(target);
}
@Override
- public String getMarkUrl(Mark mark) {
+ public String getMarkUrl(TextRange mark) {
State state = getState();
state.blobIdent.revision = resolvedRevision.name();
state.commentId = null;
@@ -852,7 +852,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
@Override
public void onSelect(AjaxRequestTarget target, BlobIdent blobIdent, @Nullable TokenPosition tokenPos) {
- mark = Mark.of(tokenPos);
+ mark = TextRange.of(tokenPos);
if (Objects.equal(DepotFilePage.this.blobIdent.path, blobIdent.path)) {
if (mark != null) {
Component fileViewer = get(FILE_VIEWER_ID);
@@ -924,7 +924,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {
if (comment != null) {
commentId = comment.getId();
- mark = comment.getMark();
+ mark = comment.getCommentPos().getRange();
} else {
commentId = null;
}
@@ -932,7 +932,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
}
@Override
- public void onAddComment(AjaxRequestTarget target, Mark mark) {
+ public void onAddComment(AjaxRequestTarget target, TextRange mark) {
commentId = null;
this.mark = mark;
pushState(target);
@@ -998,7 +998,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
public BlobIdent blobIdent = new BlobIdent();
- public Mark mark;
+ public TextRange mark;
public Mode mode;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java
index 55f59c61c8..b2ba06e581 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java
@@ -55,6 +55,7 @@ import com.pmease.gitplex.core.entity.PullRequest.Status;
import com.pmease.gitplex.core.entity.PullRequestUpdate;
import com.pmease.gitplex.core.entity.ReviewInvitation;
import com.pmease.gitplex.core.entity.component.CloseInfo;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.core.entity.component.DepotAndBranch;
import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
@@ -64,8 +65,7 @@ import com.pmease.gitplex.web.component.branchpicker.AffinalBranchPicker;
import com.pmease.gitplex.web.component.comment.CommentInput;
import com.pmease.gitplex.web.component.comment.DepotAttachmentSupport;
import com.pmease.gitplex.web.component.commitlist.CommitListPanel;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
-import com.pmease.gitplex.web.component.diff.revision.MarkSupport;
+import com.pmease.gitplex.web.component.diff.revision.CommentSupport;
import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;
import com.pmease.gitplex.web.component.pullrequest.requestassignee.AssigneeChoice;
import com.pmease.gitplex.web.component.pullrequest.requestreviewer.ReviewerAvatar;
@@ -82,7 +82,7 @@ import com.pmease.gitplex.web.page.security.LoginPage;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
@SuppressWarnings("serial")
-public class NewRequestPage extends PullRequestPage implements MarkSupport {
+public class NewRequestPage extends PullRequestPage implements CommentSupport {
private static final String TAB_PANEL_ID = "tabPanel";
@@ -96,7 +96,7 @@ public class NewRequestPage extends PullRequestPage implements MarkSupport {
private Long commentId;
- private DiffMark mark;
+ private CommentPos mark;
private String pathFilter;
@@ -692,12 +692,12 @@ public class NewRequestPage extends PullRequestPage implements MarkSupport {
}
@Override
- public DiffMark getMark() {
+ public CommentPos getMark() {
return mark;
}
@Override
- public String getMarkUrl(DiffMark mark) {
+ public String getMarkUrl(CommentPos mark) {
RevisionComparePage.State state = new RevisionComparePage.State();
state.mark = mark;
state.leftSide = new DepotAndBranch(source.getDepot(), getPullRequest().getBaseCommitHash());
@@ -721,7 +721,7 @@ public class NewRequestPage extends PullRequestPage implements MarkSupport {
public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {
if (comment != null) {
commentId = comment.getId();
- mark = new DiffMark(comment);
+ mark = comment.getCommentPos();
} else {
commentId = null;
}
@@ -730,7 +730,7 @@ public class NewRequestPage extends PullRequestPage implements MarkSupport {
@Override
public String getCommentUrl(CodeComment comment) {
RevisionComparePage.State state = new RevisionComparePage.State();
- mark = new DiffMark(comment);
+ mark = comment.getCommentPos();
state.commentId = comment.getId();
state.leftSide = new DepotAndBranch(source.getDepot(), getPullRequest().getBaseCommitHash());
state.rightSide = new DepotAndBranch(source.getDepot(), getPullRequest().getLatestUpdate().getHeadCommitHash());
@@ -742,12 +742,12 @@ public class NewRequestPage extends PullRequestPage implements MarkSupport {
}
@Override
- public void onMark(AjaxRequestTarget target, DiffMark mark) {
+ public void onMark(AjaxRequestTarget target, CommentPos mark) {
this.mark = mark;
}
@Override
- public void onAddComment(AjaxRequestTarget target, DiffMark mark) {
+ public void onAddComment(AjaxRequestTarget target, CommentPos mark) {
this.commentId = null;
this.mark = mark;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
index e9c15f74f8..6bcd65b9ab 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
@@ -43,16 +43,16 @@ import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.PullRequestUpdate;
+import com.pmease.gitplex.core.entity.component.CommentPos;
import com.pmease.gitplex.core.manager.CodeCommentManager;
-import com.pmease.gitplex.web.component.diff.revision.DiffMark;
-import com.pmease.gitplex.web.component.diff.revision.MarkSupport;
+import com.pmease.gitplex.web.component.diff.revision.CommentSupport;
import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.RequestDetailPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestlist.RequestListPage;
import com.pmease.gitplex.web.websocket.PullRequestChanged;
@SuppressWarnings("serial")
-public class RequestChangesPage extends RequestDetailPage implements MarkSupport {
+public class RequestChangesPage extends RequestDetailPage implements CommentSupport {
private static final String PARAM_OLD_COMMIT = "old-commit";
@@ -98,7 +98,7 @@ public class RequestChangesPage extends RequestDetailPage implements MarkSupport
state.blameFile = params.get(PARAM_BLAME_FILE).toString();
state.whitespaceOption = WhitespaceOption.of(params.get(PARAM_WHITESPACE_OPTION).toString());
state.commentId = params.get(PARAM_COMMENT).toOptionalLong();
- state.mark = DiffMark.of(params.get(PARAM_MARK).toString());
+ state.mark = CommentPos.of(params.get(PARAM_MARK).toString());
}
private int getCommitIndex(String commitHash) {
@@ -443,12 +443,12 @@ public class RequestChangesPage extends RequestDetailPage implements MarkSupport
}
@Override
- public DiffMark getMark() {
+ public CommentPos getMark() {
return state.mark;
}
@Override
- public String getMarkUrl(DiffMark mark) {
+ public String getMarkUrl(CommentPos mark) {
State markState = new State();
markState.mark = mark;
markState.oldCommit = state.oldCommit;
@@ -461,7 +461,7 @@ public class RequestChangesPage extends RequestDetailPage implements MarkSupport
@Override
public String getCommentUrl(CodeComment comment) {
State commentState = new State();
- commentState.mark = new DiffMark(comment);
+ commentState.mark = comment.getCommentPos();
commentState.commentId = comment.getId();
commentState.oldCommit = state.oldCommit;
commentState.newCommit = state.newCommit;
@@ -482,7 +482,7 @@ public class RequestChangesPage extends RequestDetailPage implements MarkSupport
public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {
if (comment != null) {
state.commentId = comment.getId();
- state.mark = new DiffMark(comment);
+ state.mark = comment.getCommentPos();
} else {
state.commentId = null;
}
@@ -490,13 +490,13 @@ public class RequestChangesPage extends RequestDetailPage implements MarkSupport
}
@Override
- public void onMark(AjaxRequestTarget target, DiffMark mark) {
+ public void onMark(AjaxRequestTarget target, CommentPos mark) {
state.mark = mark;
pushState(target);
}
@Override
- public void onAddComment(AjaxRequestTarget target, DiffMark mark) {
+ public void onAddComment(AjaxRequestTarget target, CommentPos mark) {
state.commentId = null;
state.mark = mark;
pushState(target);
@@ -522,7 +522,7 @@ public class RequestChangesPage extends RequestDetailPage implements MarkSupport
public Long commentId;
@Nullable
- public DiffMark mark;
+ public CommentPos mark;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.java
index 91e4f31625..e86c2e9abb 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.java
@@ -27,8 +27,8 @@ public class CodeCommentsPage extends RequestDetailPage implements CodeCommentAw
filterOption = new CodeCommentFilterOption(params);
for (CodeComment comment: getPullRequest().getCodeComments()) {
- if (comment.getPath() != null)
- commentedFiles.add(comment.getPath());
+ if (comment.getCommentPos().getPath() != null)
+ commentedFiles.add(comment.getCommentPos().getPath());
}
commentedFiles.sort((file1, file2)->Paths.get(file1).compareTo(Paths.get(file2)));
}