Skip to content

The Unified and Autonomous Development Platform

Add commit level comment

robin shined6acd89d7d3c
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
index ffac11aa4c..3f547bb85a 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
@@ -27,10 +27,14 @@ public class TextRange implements Serializable {
}
public TextRange(TextRange range) {
- this.beginLine = range.beginLine;
- this.beginChar = range.beginChar;
- this.endLine = range.endLine;
- this.endChar = range.endChar;
+ if (range != null) {
+ beginLine = range.beginLine;
+ beginChar = range.beginChar;
+ endLine = range.endLine;
+ endChar = range.endChar;
+ } else {
+ beginLine = endLine = beginChar = endChar = -1;
+ }
}
public TextRange(TokenPosition tokenPos) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js
index c4f3eb1922..249959f18e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js
@@ -583,23 +583,30 @@ gitplex.textdiff = {
scroll: function($container, mark) {
// use a timer to scroll after possible view port resize
setTimeout(function() {
- var markInfo = gitplex.textdiff.getMarkInfo($container, mark);
- var $startTd = markInfo.startTd;
- var $endTd = markInfo.endTd;
- if ($startTd && $endTd) {
- var top = $startTd.offset().top;
- var bottom = $endTd.offset().top + $endTd.outerHeight();
- var markHeight = bottom - top;
- var windowHeight = $(window).height();
- if (windowHeight <= markHeight) {
- $(window).scrollTop(top-50);
- } else {
- $(window).scrollTop((top+bottom-windowHeight)/2);
+ if (mark.beginLine != -1) {
+ var markInfo = gitplex.textdiff.getMarkInfo($container, mark);
+ var $startTd = markInfo.startTd;
+ var $endTd = markInfo.endTd;
+ if ($startTd && $endTd) {
+ var top = $startTd.offset().top;
+ var bottom = $endTd.offset().top + $endTd.outerHeight();
+ var markHeight = bottom - top;
+ var windowHeight = $(window).height();
+ if (windowHeight <= markHeight) {
+ $(window).scrollTop(top-50);
+ } else {
+ $(window).scrollTop((top+bottom-windowHeight)/2);
+ }
}
+ } else {
+ $(window).scrollTop($container.offset().top);
}
}, 0);
},
mark: function($container, mark) {
+ if (mark.beginLine == -1)
+ return;
+
gitplex.textdiff.clearMark($container);
var markInfo = gitplex.textdiff.getMarkInfo($container, mark);
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 4f1e73a361..9624f48a25 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
@@ -28,8 +28,9 @@
<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 wicket:id="commitComments" class="btn-group pull-right">
+ <a wicket:id="existing" class="btn btn-default btn-sm"><i class="fa fa-commenting"></i> Commit comments <i class="fa fa-caret-down"></i></a>
+ <a wicket:id="add" class="btn btn-default btn-sm"><i class="fa fa-plus"></i> Add commit 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>
@@ -37,7 +38,6 @@
<li wicket:id="diffStats" class="diff-stat clearfix">
<i wicket:id="icon" class="icon pull-left"></i>
<a wicket:id="file" class="file pull-left"><span wicket:id="name"></span></a>
- <span wicket:id="hasComments" title="There are comments on this file" class="has-comments pull-left"><i class="fa fa-commenting"></i></span>
<wicket:enclosure child="bar">
<span wicket:id="bar" class="bar pull-right"></span>
<span wicket:id="deletions" class="deletions pull-right"></span>
@@ -54,7 +54,7 @@
<div class="actions clearfix">
<a wicket:id="context" class="pull-left context close" title="Show this comment by comparing with specified revision"><i class="fa fa-ext fa-file-diff"></i></a>
<a wicket:id="permanent" class="pull-left permanent close" title="Permanent link of this comment"><i class="fa fa-link"></i></a>
- <a wicket:id="locate" class="pull-left locate close" title="Locate marked text of this comment"><i class="fa fa-hand-o-right"></i></a>
+ <a wicket:id="locate" class="pull-left locate close"><i class="fa fa-hand-o-right"></i></a>
<a wicket:id="close" class="pull-left close" title="Hide comment"><i class="fa fa-times"></i></a>
<a wicket:id="toggleResolve" class="pull-right resolve"><i class="fa fa-check-circle"></i></a>
</div>
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 1c7f6136d1..fbec74522b 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
@@ -168,24 +168,26 @@ public class RevisionDiffPanel extends Panel {
Set<String> markedPaths = new HashSet<>();
for (CodeComment comment: commentsModel.getObject()) {
- 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
- public Blob getBlob(BlobIdent blobIdent) {
- return depotModel.getObject().getBlob(blobIdent);
- }
-
- });
+ if (comment.getCommentPos().getPath() != null) {
+ 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
+ public Blob getBlob(BlobIdent blobIdent) {
+ return depotModel.getObject().getBlob(blobIdent);
+ }
+
+ });
+ }
+ markedPaths.add(comment.getCommentPos().getPath());
}
- markedPaths.add(comment.getCommentPos().getPath());
}
CommentPos mark = getMark();
- if (mark != null && !changedPaths.contains(mark.getPath()) && !markedPaths.contains(mark.getPath())) {
+ if (mark != null && mark.getPath() != 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);
allChanges.add(new BlobChange(null, oldBlobIdent, newBlobIdent, whitespaceOptionModel.getObject()) {
@@ -358,7 +360,23 @@ public class RevisionDiffPanel extends Panel {
};
+ private final IModel<List<CodeComment>> commitCommentsModel = new LoadableDetachableModel<List<CodeComment>>() {
+
+ @Override
+ protected List<CodeComment> load() {
+ List<CodeComment> commitComments = new ArrayList<>();
+ for (CodeComment comment: commentsModel.getObject()) {
+ if (comment.getCommentPos().getPath() == null)
+ commitComments.add(comment);
+ }
+ return commitComments;
+ }
+
+ };
+
private WebMarkupContainer commentContainer;
+
+ private WebMarkupContainer commitCommentsContainer;
private ListView<BlobChange> diffsView;
@@ -503,9 +521,9 @@ public class RevisionDiffPanel extends Panel {
});
- Form<?> form = new Form<Void>("pathFilter");
+ Form<?> pathFilterForm = new Form<Void>("pathFilter");
TextField<String> filterInput;
- form.add(filterInput = new TextField<String>("input", pathFilterModel));
+ pathFilterForm.add(filterInput = new TextField<String>("input", pathFilterModel));
Set<String> setOfInvolvedPaths = new HashSet<>();
for (DiffEntry diffEntry: diffEntriesModel.getObject()) {
@@ -526,7 +544,8 @@ public class RevisionDiffPanel extends Panel {
}
}
for (CodeComment comment: commentsModel.getObject()) {
- setOfInvolvedPaths.add(comment.getCommentPos().getPath());
+ if (comment.getCommentPos().getPath() != null)
+ setOfInvolvedPaths.add(comment.getCommentPos().getPath());
}
List<String> listOfInvolvedPaths = new ArrayList<>(setOfInvolvedPaths);
@@ -571,7 +590,7 @@ public class RevisionDiffPanel extends Panel {
});
- form.add(new AjaxButton("submit") {
+ pathFilterForm.add(new AjaxButton("submit") {
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
@@ -587,7 +606,7 @@ public class RevisionDiffPanel extends Panel {
}
});
- add(form);
+ add(pathFilterForm);
body.add(commentContainer = newCommentContainer());
@@ -601,11 +620,82 @@ public class RevisionDiffPanel extends Panel {
}));
- body.add(new AjaxLink<Void>("addComment") {
+ body.add(commitCommentsContainer = new WebMarkupContainer("commitComments"));
+ commitCommentsContainer.setOutputMarkupId(true);
+
+ commitCommentsContainer.add(new MenuLink("existing") {
@Override
- public void onClick(AjaxRequestTarget target) {
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(!commitCommentsModel.getObject().isEmpty());
+ }
+
+ @Override
+ protected List<MenuItem> getMenuItems() {
+ List<MenuItem> menuItems = new ArrayList<>();
+ for (CodeComment comment: commitCommentsModel.getObject()) {
+ Long commentId = comment.getId();
+ String title = comment.getTitle();
+ menuItems.add(new MenuItem() {
+
+ @Override
+ public String getIconClass() {
+ return null;
+ }
+
+ @Override
+ public String getLabel() {
+ return title;
+ }
+
+ @Override
+ public AbstractLink newLink(String id) {
+ return new AjaxLink<Void>(id) {
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(body));
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CodeComment comment = GitPlex.getInstance(CodeCommentManager.class).load(commentId);
+ onOpenComment(target, comment);
+ close();
+ }
+
+ };
+ }
+
+ });
+ }
+ return menuItems;
+ }
+
+ });
+
+ commitCommentsContainer.add(new AjaxLink<Void>("add") {
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(body));
+ }
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(SecurityUtils.getAccount() != null);
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CommentPos commentPos = new CommentPos();
+ commentPos.setCommit(depotModel.getObject().getRevCommit(newRev).name());
+ onAddComment(target, commentPos);
}
});
@@ -661,16 +751,6 @@ public class RevisionDiffPanel extends Panel {
fileLink.add(AttributeModifier.replace("href", "#diff-" + change.getPath()));
item.add(fileLink);
- boolean hasComments = false;
- for (CodeComment comment: commentsModel.getObject()) {
- if (change.getPaths().contains(comment.getCommentPos().getPath())) {
- hasComments = true;
- break;
- }
- }
-
- item.add(new WebMarkupContainer("hasComments").setVisible(hasComments));
-
item.add(new Label("additions", "+" + change.getAdditions()));
item.add(new Label("deletions", "-" + change.getDeletions()));
@@ -734,201 +814,12 @@ public class RevisionDiffPanel extends Panel {
@Override
public void onOpenComment(AjaxRequestTarget target, CodeComment 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(BODY_ID, 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);
- commentContainer.setVisible(true);
- target.add(commentContainer);
-
- CodeComment prevComment = RevisionDiffPanel.this.getOpenComment();
- if (prevComment != null) {
- SourceAware sourceAware = getSourceAware(prevComment.getCommentPos().getPath());
- if (sourceAware != null)
- sourceAware.onCommentClosed(target, prevComment);
- }
-
- CommentPos prevMark = RevisionDiffPanel.this.getMark();
- if (prevMark != null) {
- SourceAware sourceAware = getSourceAware(prevMark.getPath());
- if (sourceAware != null)
- sourceAware.mark(target, null);
- }
-
- commentSupport.onCommentOpened(target, comment);
- target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ RevisionDiffPanel.this.onOpenComment(target, comment);
}
@Override
- public 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();");
+ public void onAddComment(AjaxRequestTarget target, CommentPos commentPos) {
+ RevisionDiffPanel.this.onAddComment(target, commentPos);
}
@Override
@@ -958,9 +849,67 @@ public class RevisionDiffPanel extends Panel {
setOutputMarkupId(true);
}
+
+ private void onOpenComment(AjaxRequestTarget target, CodeComment 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(BODY_ID, 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);
+ commentContainer.setVisible(true);
+ target.add(commentContainer);
+
+ CodeComment prevComment = RevisionDiffPanel.this.getOpenComment();
+ if (prevComment != null) {
+ SourceAware sourceAware = getSourceAware(prevComment.getCommentPos().getPath());
+ if (sourceAware != null)
+ sourceAware.onCommentClosed(target, prevComment);
+ }
+
+ CommentPos prevMark = RevisionDiffPanel.this.getMark();
+ if (prevMark != null) {
+ SourceAware sourceAware = getSourceAware(prevMark.getPath());
+ if (sourceAware != null)
+ sourceAware.mark(target, null);
+ }
+
+ commentSupport.onCommentOpened(target, comment);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
- private void onAddComment(AjaxRequestTarget target, CommentPos mark) {
- commentContainer.setDefaultModelObject(mark);
+ private void onAddComment(AjaxRequestTarget target, CommentPos commentPos) {
+ commentContainer.setDefaultModelObject(commentPos);
Fragment fragment = new Fragment(BODY_ID, "newCommentFrag", RevisionDiffPanel.this);
fragment.setOutputMarkupId(true);
@@ -1024,7 +973,7 @@ public class RevisionDiffPanel extends Panel {
comment.setUUID(uuid);
comment.setDepot(depotModel.getObject());
comment.setUser(SecurityUtils.getAccount());
- comment.setCommentPos(mark);
+ comment.setCommentPos(commentPos);
comment.setCompareContext(getCompareContext(comment.getCommentPos().getCommit()));
comment.setTitle(titleInput.getModelObject());
comment.setContent(contentInput.getModelObject());
@@ -1066,6 +1015,9 @@ public class RevisionDiffPanel extends Panel {
commentContainer.replace(commentPanel);
target.add(commentContainer);
+ if (comment.getCommentPos().getPath() == null)
+ target.add(commitCommentsContainer);
+
SourceAware sourceAware = getSourceAware(comment.getCommentPos().getPath());
if (sourceAware != null)
sourceAware.onCommentAdded(target, comment);
@@ -1094,7 +1046,7 @@ public class RevisionDiffPanel extends Panel {
if (sourceAware != null)
sourceAware.onCommentClosed(target, prevComment);
}
- commentSupport.onAddComment(target, mark);
+ commentSupport.onAddComment(target, commentPos);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
}
@@ -1260,22 +1212,44 @@ public class RevisionDiffPanel extends Panel {
@Override
protected void onInitialize() {
super.onInitialize();
+
+ add(AttributeAppender.append("title", new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ CommentPos commentPos = getCommentPos();
+ if (commentPos.getRange() != null)
+ return "Locate the text this comment applied to";
+ else
+ return "Locate the file this comment applied to";
+ }
+
+ }));
setOutputMarkupId(true);
}
- @Override
- public void onClick(AjaxRequestTarget target) {
+ private CommentPos getCommentPos() {
CodeComment comment = getOpenComment();
- CommentPos mark;
if (comment != null) {
- mark = comment.getCommentPos();
+ return comment.getCommentPos();
} else {
- mark = (CommentPos)commentContainer.getDefaultModelObject();
+ return (CommentPos)commentContainer.getDefaultModelObject();
}
- SourceAware sourceAware = getSourceAware(mark.getPath());
+ }
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(getCommentPos().getPath() != null);
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CommentPos commentPos = getCommentPos();
+ SourceAware sourceAware = getSourceAware(commentPos.getPath());
if (sourceAware != null)
- sourceAware.mark(target, mark);
- commentSupport.onMark(target, mark);
+ sourceAware.mark(target, commentPos);
+ commentSupport.onMark(target, commentPos);
target.appendJavaScript(String.format("$('#%s').blur();", getMarkupId()));
}
@@ -1391,11 +1365,15 @@ public class RevisionDiffPanel extends Panel {
boolean locatable = false;
CodeComment comment = getOpenComment();
if (comment != null) {
- for (BlobChange change: changesAndCountModel.getObject().getChanges()) {
- if (change.getPaths().contains(comment.getCommentPos().getPath())) {
- locatable = true;
- break;
+ if (comment.getCommentPos().getPath() != null) {
+ for (BlobChange change: changesAndCountModel.getObject().getChanges()) {
+ if (change.getPaths().contains(comment.getCommentPos().getPath())) {
+ locatable = true;
+ break;
+ }
}
+ } else {
+ locatable = true;
}
}
@@ -1505,6 +1483,8 @@ public class RevisionDiffPanel extends Panel {
if (sourceAware != null)
sourceAware.onCommentDeleted(target, comment);
commentSupport.onCommentOpened(target, null);
+ if (comment.getCommentPos().getPath() == null)
+ target.add(commitCommentsContainer);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
CommentPos mark = getMark();
if (mark != null) {
@@ -1523,6 +1503,7 @@ public class RevisionDiffPanel extends Panel {
@Override
protected void onDetach() {
+ commitCommentsModel.detach();
commentsModel.detach();
diffEntriesModel.detach();
changesAndCountModel.detach();