Skip to content

The Unified and Autonomous Development Platform

Draft version of code comment list

robin shine6b64524cae0a
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.css b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.css
index 6a0a0c851b..7c01cee477 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.css
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.css
@@ -8,11 +8,6 @@
cursor: pointer;
}
-/* TEXT AREA */
-textarea {
- max-height: 600px;
-}
-
/* TOOLTIPS */
.tooltip-inner {
max-width: 400px;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java
index 0d2f9f2641..7362ffce0c 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java
@@ -18,10 +18,12 @@ import com.pmease.commons.loader.AbstractPluginModule;
import com.pmease.commons.loader.ImplementationProvider;
import com.pmease.commons.shiro.AbstractRealm;
import com.pmease.commons.util.ClassUtils;
+import com.pmease.gitplex.core.entity.CodeCommentReply;
import com.pmease.gitplex.core.entity.Config;
import com.pmease.gitplex.core.entity.EntityLocator;
import com.pmease.gitplex.core.entity.persistlistener.ListenerLocator;
import com.pmease.gitplex.core.listener.CodeCommentListener;
+import com.pmease.gitplex.core.listener.CodeCommentReplyListener;
import com.pmease.gitplex.core.listener.ConfigListener;
import com.pmease.gitplex.core.listener.DepotListener;
import com.pmease.gitplex.core.listener.LifecycleListener;
@@ -235,6 +237,18 @@ public class CoreModule extends AbstractPluginModule {
}
});
+ contribute(CodeCommentReplyListener.class, new CodeCommentReplyListener() {
+
+ @Override
+ public void onSaveReply(CodeCommentReply reply) {
+ }
+
+ @Override
+ public void onDeleteReply(CodeCommentReply reply) {
+ }
+
+ });
+
contributeFromPackage(PersistListener.class, ListenerLocator.class);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/AccountChoice.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/AccountChoice.java
new file mode 100644
index 0000000000..c45cf3f7cd
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/AccountChoice.java
@@ -0,0 +1,12 @@
+package com.pmease.gitplex.core.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AccountChoice {
+ boolean organization() default false;
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/UserChoice.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/FileChoice.java
similarity index 85%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/UserChoice.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/FileChoice.java
index d39a7ff2b3..ad8e08441a 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/UserChoice.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/annotation/FileChoice.java
@@ -1,11 +1,12 @@
-package com.pmease.gitplex.core.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface UserChoice {
-}
+package com.pmease.gitplex.core.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface FileChoice {
+ String value();
+}
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 45ddab93c4..b0cb44936f 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
@@ -51,6 +51,9 @@ public class CodeComment extends AbstractEntity {
@ManyToOne(fetch=FetchType.LAZY)
private Account user;
+ @Column(nullable=false)
+ private String title;
+
@Lob
@Column(nullable=false, length=65535)
private String content;
@@ -61,6 +64,8 @@ public class CodeComment extends AbstractEntity {
@Column(nullable=false)
private Date updateDate = new Date();
+ private String lastReplyUser;
+
@OptimisticLock(excluded=true)
@Column(nullable=false)
private String commit;
@@ -107,6 +112,15 @@ public class CodeComment extends AbstractEntity {
return version;
}
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Nullable
public String getContent() {
return content;
}
@@ -203,4 +217,12 @@ public class CodeComment extends AbstractEntity {
this.resolved = resolved;
}
+ public String getLastReplyUser() {
+ return lastReplyUser;
+ }
+
+ public void setLastReplyUser(String lastReplyUser) {
+ this.lastReplyUser = lastReplyUser;
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
index e2965babdb..f6bfd31e4d 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
@@ -48,6 +48,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Blocking;
import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;
import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;
+import com.pmease.gitplex.core.manager.CodeCommentRelationManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.core.manager.ReviewManager;
import com.pmease.gitplex.core.security.ObjectPermission;
@@ -264,6 +265,8 @@ public class PullRequest extends AbstractEntity {
private transient IntegrationPreview integrationPreview;
+ private transient List<CodeComment> codeComments;
+
/**
* Get title of this merge request.
*
@@ -937,4 +940,11 @@ public class PullRequest extends AbstractEntity {
numberStr = String.valueOf(number);
}
+ public List<CodeComment> getCodeComments() {
+ if (codeComments == null) {
+ codeComments = GitPlex.getInstance(CodeCommentRelationManager.class).queryCodeComments(this);
+ }
+ return codeComments;
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java
index 671c313dfe..d1cc7d8509 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java
@@ -1,75 +1,75 @@
-package com.pmease.gitplex.core.gatekeeper;
-
-import org.eclipse.jgit.lib.ObjectId;
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.pmease.commons.wicket.editable.annotation.Editable;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.annotation.UserChoice;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.Review;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
-import com.pmease.gitplex.core.manager.AccountManager;
-
-@Editable(order=200, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is approved by specified user")
-public class IfApprovedBySpecifiedUser extends AbstractGateKeeper {
-
- private static final long serialVersionUID = 1L;
-
- private String userName;
-
- @Editable(name="Select User Below")
- @UserChoice
- @NotEmpty
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- public CheckResult doCheckRequest(PullRequest request) {
- Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
-
- Review.Result result = user.checkReviewSince(request.getReferentialUpdate());
- if (result == null) {
- request.pickReviewers(Sets.newHashSet(user), 1);
-
- return pending(Lists.newArrayList("To be approved by " + user.getDisplayName()));
- } else if (result == Review.Result.APPROVE) {
- return passed(Lists.newArrayList("Approved by " + user.getDisplayName()));
- } else {
- return failed(Lists.newArrayList("Disapproved by " + user.getDisplayName()));
- }
- }
-
- @Override
- protected CheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
- return pending(Lists.newArrayList("Need approval from " + user.getName()));
- }
-
- @Override
- protected CheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
- return pending(Lists.newArrayList("Need approval from " + user.getName()));
- }
-
- @Override
- public void onAccountRename(String oldName, String newName) {
- if (userName.equals(oldName))
- userName = newName;
- }
-
- @Override
- public boolean onAccountDelete(String accountName) {
- return userName.equals(accountName);
- }
-
-}
+package com.pmease.gitplex.core.gatekeeper;
+
+import org.eclipse.jgit.lib.ObjectId;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.Review;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
+import com.pmease.gitplex.core.manager.AccountManager;
+
+@Editable(order=200, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
+ "This gate keeper will be passed if the commit is approved by specified user")
+public class IfApprovedBySpecifiedUser extends AbstractGateKeeper {
+
+ private static final long serialVersionUID = 1L;
+
+ private String userName;
+
+ @Editable(name="Select User Below")
+ @AccountChoice
+ @NotEmpty
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public CheckResult doCheckRequest(PullRequest request) {
+ Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
+
+ Review.Result result = user.checkReviewSince(request.getReferentialUpdate());
+ if (result == null) {
+ request.pickReviewers(Sets.newHashSet(user), 1);
+
+ return pending(Lists.newArrayList("To be approved by " + user.getDisplayName()));
+ } else if (result == Review.Result.APPROVE) {
+ return passed(Lists.newArrayList("Approved by " + user.getDisplayName()));
+ } else {
+ return failed(Lists.newArrayList("Disapproved by " + user.getDisplayName()));
+ }
+ }
+
+ @Override
+ protected CheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
+ return pending(Lists.newArrayList("Need approval from " + user.getName()));
+ }
+
+ @Override
+ protected CheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
+ return pending(Lists.newArrayList("Need approval from " + user.getName()));
+ }
+
+ @Override
+ public void onAccountRename(String oldName, String newName) {
+ if (userName.equals(oldName))
+ userName = newName;
+ }
+
+ @Override
+ public boolean onAccountDelete(String accountName) {
+ return userName.equals(accountName);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java
index 8f9c388fa0..ddcb017890 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java
@@ -1,73 +1,73 @@
-package com.pmease.gitplex.core.gatekeeper;
-
-import org.eclipse.jgit.lib.ObjectId;
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.pmease.commons.wicket.editable.annotation.Editable;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.annotation.UserChoice;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.Review;
-import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
-import com.pmease.gitplex.core.manager.AccountManager;
-
-@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is disapproved by specified user. "
- + "It normally works together with a NOT container to reject the pull request "
- + "in case the user disapproved it")
-public class IfDisapprovedBySpecifiedUser extends AbstractGateKeeper {
-
- private static final long serialVersionUID = 1L;
-
- private String userName;
-
- @Editable(name="Select User Below")
- @UserChoice
- @NotEmpty
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- protected CheckResult doCheckRequest(PullRequest request) {
- Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class)
- .findByName(userName));
- Review.Result result = user.checkReviewSince(request.getReferentialUpdate());
- if (result == Review.Result.DISAPPROVE) {
- return passed(Lists.newArrayList("Disapproved by " + userName));
- } else {
- return failed(Lists.newArrayList("Not disapproved by " + userName));
- }
- }
-
- @Override
- protected CheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
- return failed(Lists.newArrayList("Not disapproved by " + userName));
- }
-
- @Override
- protected CheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit,
- ObjectId newCommit) {
- return failed(Lists.newArrayList("Not disapproved by " + userName));
- }
-
- @Override
- public void onAccountRename(String oldName, String newName) {
- if (userName.equals(oldName))
- userName = newName;
- }
-
- @Override
- public boolean onAccountDelete(String accountName) {
- return userName.equals(accountName);
- }
-
-}
+package com.pmease.gitplex.core.gatekeeper;
+
+import org.eclipse.jgit.lib.ObjectId;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.Review;
+import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
+import com.pmease.gitplex.core.manager.AccountManager;
+
+@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=
+ "This gate keeper will be passed if the commit is disapproved by specified user. "
+ + "It normally works together with a NOT container to reject the pull request "
+ + "in case the user disapproved it")
+public class IfDisapprovedBySpecifiedUser extends AbstractGateKeeper {
+
+ private static final long serialVersionUID = 1L;
+
+ private String userName;
+
+ @Editable(name="Select User Below")
+ @AccountChoice
+ @NotEmpty
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ protected CheckResult doCheckRequest(PullRequest request) {
+ Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class)
+ .findByName(userName));
+ Review.Result result = user.checkReviewSince(request.getReferentialUpdate());
+ if (result == Review.Result.DISAPPROVE) {
+ return passed(Lists.newArrayList("Disapproved by " + userName));
+ } else {
+ return failed(Lists.newArrayList("Not disapproved by " + userName));
+ }
+ }
+
+ @Override
+ protected CheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
+ return failed(Lists.newArrayList("Not disapproved by " + userName));
+ }
+
+ @Override
+ protected CheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit,
+ ObjectId newCommit) {
+ return failed(Lists.newArrayList("Not disapproved by " + userName));
+ }
+
+ @Override
+ public void onAccountRename(String oldName, String newName) {
+ if (userName.equals(oldName))
+ userName = newName;
+ }
+
+ @Override
+ public boolean onAccountDelete(String accountName) {
+ return userName.equals(accountName);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java
index daa27e0ddc..ec4085c193 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java
@@ -1,70 +1,70 @@
-package com.pmease.gitplex.core.gatekeeper;
-
-import org.eclipse.jgit.lib.ObjectId;
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.pmease.commons.wicket.editable.annotation.Editable;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.annotation.UserChoice;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
-import com.pmease.gitplex.core.manager.AccountManager;
-
-@Editable(order=600, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is submitted by specified user")
-public class IfSubmittedBySpecifiedUser extends AbstractGateKeeper {
-
- private static final long serialVersionUID = 1L;
-
- private String userName;
-
- @Editable(name="Select User Below")
- @UserChoice
- @NotEmpty
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- public CheckResult doCheckRequest(PullRequest request) {
- return checkSubmitter(request.getSubmitter());
- }
-
- private CheckResult checkSubmitter(Account user) {
- Account expectedUser = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
- if (expectedUser.equals(user))
- return passed(Lists.newArrayList("Submitted by " + expectedUser.getDisplayName()));
- else
- return failed(Lists.newArrayList("Not submitted by " + expectedUser.getDisplayName()));
- }
-
- @Override
- protected CheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
- return checkSubmitter(user);
- }
-
- @Override
- protected CheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
- return checkSubmitter(user);
- }
-
- @Override
- public void onAccountRename(String oldName, String newName) {
- if (userName.equals(oldName))
- userName = newName;
- }
-
- @Override
- public boolean onAccountDelete(String accountName) {
- return userName.equals(accountName);
- }
-
-}
+package com.pmease.gitplex.core.gatekeeper;
+
+import org.eclipse.jgit.lib.ObjectId;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
+import com.pmease.gitplex.core.manager.AccountManager;
+
+@Editable(order=600, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
+ "This gate keeper will be passed if the commit is submitted by specified user")
+public class IfSubmittedBySpecifiedUser extends AbstractGateKeeper {
+
+ private static final long serialVersionUID = 1L;
+
+ private String userName;
+
+ @Editable(name="Select User Below")
+ @AccountChoice
+ @NotEmpty
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public CheckResult doCheckRequest(PullRequest request) {
+ return checkSubmitter(request.getSubmitter());
+ }
+
+ private CheckResult checkSubmitter(Account user) {
+ Account expectedUser = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
+ if (expectedUser.equals(user))
+ return passed(Lists.newArrayList("Submitted by " + expectedUser.getDisplayName()));
+ else
+ return failed(Lists.newArrayList("Not submitted by " + expectedUser.getDisplayName()));
+ }
+
+ @Override
+ protected CheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
+ return checkSubmitter(user);
+ }
+
+ @Override
+ protected CheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
+ return checkSubmitter(user);
+ }
+
+ @Override
+ public void onAccountRename(String oldName, String newName) {
+ if (userName.equals(oldName))
+ userName = newName;
+ }
+
+ @Override
+ public boolean onAccountDelete(String accountName) {
+ return userName.equals(accountName);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentRelationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentRelationManager.java
index 8df2d95127..161d603ba8 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentRelationManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentRelationManager.java
@@ -9,6 +9,9 @@ import com.pmease.gitplex.core.entity.PullRequest;
public interface CodeCommentRelationManager extends EntityDao<CodeCommentRelation> {
+ /**
+ * Get code comments related to specified pull request, ordered by id descendantly
+ */
List<CodeComment> queryCodeComments(PullRequest request);
}
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 b8cce3a639..85d75d3aff 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
@@ -101,8 +101,7 @@ public class DefaultCodeCommentInfoManager implements CodeCommentInfoManager, De
if (env == null) {
EnvironmentConfig config = new EnvironmentConfig();
config.setLogCacheShared(false);
- config.setMemoryUsage(1024*1024*64);
- config.setLogFileSize(64*1024);
+ config.setMemoryUsage(1024*1024*16);
env = Environments.newInstance(getInfoDir(depot), config);
envs.put(depot.getId(), env);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentRelationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentRelationManager.java
index 558af83a9a..ef2a43ce01 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentRelationManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentRelationManager.java
@@ -2,6 +2,7 @@ package com.pmease.gitplex.core.manager.impl;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -111,6 +112,8 @@ public class DefaultCodeCommentRelationManager extends AbstractEntityDao<CodeCom
for (CodeCommentRelation relation: request.getCodeCommentRelations()) {
comments.add(relation.getComment());
}
+ comments.sort(CodeComment::compareTo);
+ Collections.reverse(comments);
return comments;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentReplyManager.java
index 25e5ae0469..6fbc87dedd 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentReplyManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentReplyManager.java
@@ -1,5 +1,8 @@
package com.pmease.gitplex.core.manager.impl;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Set;
import javax.inject.Inject;
@@ -9,6 +12,7 @@ import javax.inject.Singleton;
import com.pmease.commons.hibernate.Transactional;
import com.pmease.commons.hibernate.dao.AbstractEntityDao;
import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.CodeCommentReply;
import com.pmease.gitplex.core.listener.CodeCommentReplyListener;
import com.pmease.gitplex.core.manager.CodeCommentManager;
@@ -37,6 +41,7 @@ public class DefaultCodeCommentReplyManager extends AbstractEntityDao<CodeCommen
listener.onSaveReply(reply);
persist(reply);
reply.getComment().setUpdateDate(reply.getDate());
+ reply.getComment().setLastReplyUser(reply.getUser().getDisplayName());
codeCommentManager.save(reply.getComment());
}
@@ -45,6 +50,18 @@ public class DefaultCodeCommentReplyManager extends AbstractEntityDao<CodeCommen
public void delete(CodeCommentReply reply) {
for (CodeCommentReplyListener listener: listenersProvider.get())
listener.onDeleteReply(reply);
+ CodeComment comment = reply.getComment();
+ List<CodeCommentReply> replies = new ArrayList<>(comment.getReplies());
+ replies.remove(reply);
+ Collections.sort(replies);
+ if (replies.isEmpty()) {
+ comment.setLastReplyUser(null);
+ comment.setUpdateDate(comment.getCreateDate());
+ } else {
+ CodeCommentReply lastReply = replies.get(replies.size()-1);
+ comment.setLastReplyUser(lastReply.getUser().getDisplayName());
+ comment.setUpdateDate(lastReply.getDate());
+ }
remove(reply);
}
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInfoManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInfoManager.java
index 4959afc485..8aeb6ce959 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInfoManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInfoManager.java
@@ -105,8 +105,7 @@ public class DefaultPullRequestInfoManager implements PullRequestInfoManager, De
if (env == null) {
EnvironmentConfig config = new EnvironmentConfig();
config.setLogCacheShared(false);
- config.setMemoryUsage(1024*1024*64);
- config.setLogFileSize(64*1024);
+ config.setMemoryUsage(1024*1024*16);
env = Environments.newInstance(getInfoDir(depot), config);
envs.put(depot.getId(), env);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountchoice/AccountChoiceProvider.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountchoice/AccountChoiceProvider.java
index 66242f4075..61546f5b0b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountchoice/AccountChoiceProvider.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountchoice/AccountChoiceProvider.java
@@ -1,39 +1,48 @@
-package com.pmease.gitplex.web.component.accountchoice;
-
-import java.util.List;
-
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.MatchMode;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Restrictions;
-
-import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.commons.hibernate.dao.EntityCriteria;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.web.Constants;
-import com.vaynberg.wicket.select2.Response;
-
-public class AccountChoiceProvider extends AbstractAccountChoiceProvider {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void query(String term, int page, Response<Account> response) {
- Dao dao = GitPlex.getInstance(Dao.class);
- int first = page * Constants.DEFAULT_PAGE_SIZE;
- Criterion criterion = Restrictions.and(Restrictions.or(
- Restrictions.ilike("name", term, MatchMode.ANYWHERE),
- Restrictions.ilike("fullName", term, MatchMode.ANYWHERE)));
- List<Account> accounts = dao.query(EntityCriteria.of(Account.class)
- .add(criterion).addOrder(Order.asc("name")), first, Constants.DEFAULT_PAGE_SIZE + 1);
-
- if (accounts.size() <= Constants.DEFAULT_PAGE_SIZE) {
- response.addAll(accounts);
- } else {
- response.addAll(accounts.subList(0, Constants.DEFAULT_PAGE_SIZE));
- response.setHasMore(true);
- }
- }
-
+package com.pmease.gitplex.web.component.accountchoice;
+
+import java.util.List;
+
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.MatchMode;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.web.Constants;
+import com.vaynberg.wicket.select2.Response;
+
+public class AccountChoiceProvider extends AbstractAccountChoiceProvider {
+
+ private static final long serialVersionUID = 1L;
+
+ private final boolean organization;
+
+ public AccountChoiceProvider(boolean organization) {
+ this.organization = organization;
+ }
+
+ @Override
+ public void query(String term, int page, Response<Account> response) {
+ Dao dao = GitPlex.getInstance(Dao.class);
+ int first = page * Constants.DEFAULT_PAGE_SIZE;
+ Criterion criterion = Restrictions.and(Restrictions.or(
+ Restrictions.ilike("name", term, MatchMode.ANYWHERE),
+ Restrictions.ilike("fullName", term, MatchMode.ANYWHERE)));
+ EntityCriteria<Account> criteria = EntityCriteria.of(Account.class);
+ criteria.add(criterion);
+ criteria.add(Restrictions.eq("organization", organization));
+ criteria.addOrder(Order.asc("name"));
+ List<Account> accounts = dao.query(criteria, first, Constants.DEFAULT_PAGE_SIZE + 1);
+
+ if (accounts.size() <= Constants.DEFAULT_PAGE_SIZE) {
+ response.addAll(accounts);
+ } else {
+ response.addAll(accounts.subList(0, Constants.DEFAULT_PAGE_SIZE));
+ response.setHasMore(true);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentAware.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentAware.java
new file mode 100644
index 0000000000..e61d2a4f05
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentAware.java
@@ -0,0 +1,7 @@
+package com.pmease.gitplex.web.component.comment;
+
+import java.util.List;
+
+public interface CodeCommentAware {
+ List<String> getCommentedFiles();
+}
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
new file mode 100644
index 0000000000..bbee6b07f7
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilterOption.java
@@ -0,0 +1,207 @@
+package com.pmease.gitplex.web.component.comment;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.commons.util.match.WildcardUtils;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.annotation.FileChoice;
+import com.pmease.gitplex.core.entity.CodeComment;
+
+@Editable
+public class CodeCommentFilterOption implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String PARAM_USER = "user";
+
+ private static final String PARAM_UNRESOLVED = "unresolved";
+
+ private static final String PARAM_PATH = "path";
+
+ private static final String PARAM_CONTENT = "content";
+
+ private static final String PARAM_BEFORE = "before";
+
+ private static final String PARAM_AFTER = "after";
+
+ private String userName;
+
+ private boolean unresolved;
+
+ private String path;
+
+ private String content;
+
+ private Date before;
+
+ private Date after;
+
+ @Editable(order=100, name="Created by", description="Choose the user who created the comment")
+ @AccountChoice
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Editable(order=200, name="Show unresolved only", description="Check this if you only want to show unresolved comments")
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ @Editable(order=400, name="Content containing", description="Show comments with content containing specified string")
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ @Editable(order=500, name="Commented path", description="Show comments on specified path")
+ @FileChoice("getCommentedFiles")
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Editable(order=600, name="After date", description="Show comments after specified date")
+ public Date getAfter() {
+ return after;
+ }
+
+ public void setAfter(Date after) {
+ this.after = after;
+ }
+
+ @Editable(order=700, name="Before date", description="Show comments before specified date")
+ public Date getBefore() {
+ return before;
+ }
+
+ public void setBefore(Date before) {
+ this.before = before;
+ }
+
+ public CodeCommentFilterOption() {
+ }
+
+ public CodeCommentFilterOption(PageParameters params) {
+ userName = params.get(PARAM_USER).toString();
+ unresolved = "yes".equals(params.get(PARAM_UNRESOLVED).toString());
+ path = params.get(PARAM_PATH).toString();
+ content = params.get(PARAM_CONTENT).toString();
+
+ String value = params.get(PARAM_BEFORE).toString();
+ if (value != null)
+ before = new Date(Long.valueOf(value));
+
+ value = params.get(PARAM_AFTER).toString();
+ if (value != null)
+ after = new Date(Long.valueOf(value));
+ }
+
+ public void fill(EntityCriteria<CodeComment> criteria) {
+ if (userName != null)
+ criteria.createCriteria("user").add(Restrictions.eq("name", userName));
+ if (unresolved)
+ criteria.add(Restrictions.eq("resolved", false));
+ if (path != null) {
+ String pathQuery = path.replace('*', '%');
+ if (pathQuery.endsWith("/"))
+ pathQuery += "%";
+ criteria.add(Restrictions.ilike("path", pathQuery));
+ }
+ if (content != null)
+ criteria.add(Restrictions.ilike("content", "%" + content + "%"));
+
+ if (before != null)
+ criteria.add(Restrictions.le("createDate", before));
+ if (after != null)
+ criteria.add(Restrictions.ge("createDate", after));
+ }
+
+ public void filter(Collection<CodeComment> comments) {
+ for (Iterator<CodeComment> it = comments.iterator(); it.hasNext();) {
+ CodeComment comment = it.next();
+ if (userName != null) {
+ if (comment.getUser() == null || !comment.getUser().getName().equals(userName)) {
+ it.remove();
+ continue;
+ }
+ }
+ if (unresolved && comment.isResolved()) {
+ it.remove();
+ continue;
+ }
+ if (path != null) {
+ if (comment.getPath() == null) {
+ it.remove();
+ continue;
+ } else {
+ String matchWith = path;
+ if (matchWith.endsWith("/"))
+ matchWith += "*";
+ if (!WildcardUtils.matchString(matchWith, comment.getPath())) {
+ it.remove();
+ continue;
+ }
+ }
+ }
+ if (content != null && !comment.getContent().contains(content)) {
+ it.remove();
+ continue;
+ }
+ if (before != null && comment.getCreateDate().after(before)) {
+ it.remove();
+ continue;
+ }
+ if (after != null && comment.getCreateDate().before(after)) {
+ it.remove();
+ continue;
+ }
+ }
+ }
+
+ public void fillPageParams(PageParameters params) {
+ if (userName != null)
+ params.add(PARAM_USER, userName);
+ if (unresolved)
+ params.add(PARAM_UNRESOLVED, "yes");
+ if (content != null)
+ params.add(PARAM_CONTENT, content);
+ if (path != null)
+ params.add(PARAM_PATH, path);
+ if (before != null)
+ params.add(PARAM_BEFORE, before.getTime());
+ if (after != null)
+ params.add(PARAM_AFTER, after.getTime());
+ }
+
+ @SuppressWarnings("unused")
+ private static List<String> getCommentedFiles() {
+ RenderPageRequestHandler handler = (RenderPageRequestHandler) RequestCycle.get().getActiveRequestHandler();
+ return ((CodeCommentAware)handler.getPage()).getCommentedFiles();
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.html
new file mode 100644
index 0000000000..150faf350f
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.html
@@ -0,0 +1,45 @@
+<wicket:panel>
+ <table class="code-comments">
+ <tr>
+ <td class="filter">
+ <div class="head">Filter options</div>
+ <div class="body">
+ <div class="btn-group shortcuts">
+ <a wicket:id="myComments" class="btn btn-sm btn-default">My</a>
+ <a wicket:id="myUnresolvedComments" class="btn btn-sm btn-default">My unresolved</a>
+ <a wicket:id="unresolvedComments" class="btn btn-sm btn-default">Unresolved</a>
+ <a wicket:id="allComments" class="btn btn-sm btn-default">All</a>
+ </div>
+ <form wicket:id="filterForm">
+ <div wicket:id="editor"></div>
+ <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> Search</button>
+ </form>
+ </div>
+ </td>
+ <td class="spacing">&nbsp;</td>
+ <td class="result">
+ <table wicket:id="comments"></table>
+ </td>
+ </tr>
+ </table>
+ <wicket:fragment wicket:id="commentFrag">
+ <a wicket:id="link">
+ <div class="first-line">
+ <span wicket:id="title" class="title"></span>
+ <span wicket:id="resolved" class="resolved fa fa-tick"></span>
+ </div>
+ <div class="second-line">
+ Commented by
+ <span wicket:id="user" class="user"></span>
+ on
+ <span wicket:id="what" class="what"></span>
+ <span wicket:id="age" class="age"></span>
+ </div>
+ <div wicket:id="lastReply" class="third-line">
+ Last replied by
+ <span wicket:id="user" class="user"></span>
+ <span wicket:id="age" class="age"></span>
+ </div>
+ </a>
+ </wicket:fragment>
+</wicket:panel>
\ No newline at end of file
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
new file mode 100644
index 0000000000..9ca49e2459
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.java
@@ -0,0 +1,234 @@
+package com.pmease.gitplex.web.component.comment;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.NoRecordsToolbar;
+import org.apache.wicket.markup.head.CssHeaderItem;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.resource.CssResourceReference;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.commons.wicket.editable.BeanContext;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.CodeComment;
+import com.pmease.gitplex.core.entity.PullRequest;
+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.page.depot.DepotPage;
+import com.pmease.gitplex.web.util.DateUtils;
+
+@SuppressWarnings("serial")
+public abstract class CodeCommentListPanel extends Panel {
+
+ private final IModel<CodeCommentFilterOption> filterOptionModel;
+
+ public CodeCommentListPanel(String id, IModel<CodeCommentFilterOption> filterOptionModel) {
+ super(id);
+
+ this.filterOptionModel = filterOptionModel;
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(new Link<Void>("myComments") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(SecurityUtils.getAccount() != null);
+ }
+
+ @Override
+ public void onClick() {
+ CodeCommentFilterOption filterOption = new CodeCommentFilterOption();
+ filterOption.setUserName(SecurityUtils.getAccount().getName());
+ filterOptionModel.setObject(filterOption);
+ }
+
+ });
+ add(new Link<Void>("myUnresolvedComments") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(SecurityUtils.getAccount() != null);
+ }
+
+ @Override
+ public void onClick() {
+ CodeCommentFilterOption filterOption = new CodeCommentFilterOption();
+ filterOption.setUserName(SecurityUtils.getAccount().getName());
+ filterOption.setUnresolved(true);
+ filterOptionModel.setObject(filterOption);
+ }
+
+ });
+ add(new Link<Void>("unresolvedComments") {
+
+ @Override
+ public void onClick() {
+ CodeCommentFilterOption filterOption = new CodeCommentFilterOption();
+ filterOption.setUnresolved(true);
+ filterOptionModel.setObject(filterOption);
+ }
+
+ });
+ add(new Link<Void>("allComments") {
+
+ @Override
+ public void onClick() {
+ filterOptionModel.setObject(new CodeCommentFilterOption());
+ }
+
+ });
+ Form<?> filterForm = new Form<Void>("filterForm") {
+
+ @Override
+ protected void onSubmit() {
+ super.onSubmit();
+ }
+
+ };
+ filterForm.add(BeanContext.editModel("editor", filterOptionModel));
+ add(filterForm);
+
+ List<IColumn<CodeComment, Void>> columns = new ArrayList<>();
+ columns.add(new AbstractColumn<CodeComment, Void>(Model.of("Code Comment")) {
+
+ @Override
+ public void populateItem(Item<ICellPopulator<CodeComment>> cellItem,
+ String componentId, IModel<CodeComment> rowModel) {
+ CodeComment comment = rowModel.getObject();
+ Fragment fragment = new Fragment(componentId, "commentFrag", CodeCommentListPanel.this);
+ Link<Void> link = new Link<Void>("link") {
+
+ @Override
+ public void onClick() {
+ }
+
+ };
+ 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()));
+ else
+ link.add(new Label("what", comment.getCommit()));
+ link.add(new Label("age", DateUtils.formatAge(comment.getCreateDate())));
+
+ WebMarkupContainer lastReply = new WebMarkupContainer("lastReply");
+ lastReply.setVisible(comment.getLastReplyUser() != null);
+ lastReply.add(new Label("user", comment.getLastReplyUser()));
+ lastReply.add(new Label("age", DateUtils.formatAge(comment.getUpdateDate())));
+ link.add(lastReply);
+
+ fragment.add(link);
+ cellItem.add(fragment);
+ cellItem.add(AttributeAppender.append("class", "comment"));
+ }
+
+ });
+
+ IDataProvider<CodeComment> dataProvider = new IDataProvider<CodeComment>() {
+
+ @Override
+ public void detach() {
+ }
+
+ @Override
+ public Iterator<? extends CodeComment> iterator(long first, long count) {
+ DepotPage page = (DepotPage) getPage();
+
+ if (getPullRequest() != null) {
+ List<CodeComment> comments = new ArrayList<>(getPullRequest().getCodeComments());
+ filterOptionModel.getObject().filter(comments);
+ return comments.iterator();
+ } else {
+ EntityCriteria<CodeComment> criteria = EntityCriteria.of(CodeComment.class);
+ criteria.add(Restrictions.eq("depot", page.getDepot()));
+ filterOptionModel.getObject().fill(criteria);
+ criteria.addOrder(Order.desc("id"));
+ return GitPlex.getInstance(Dao.class).query(criteria, (int)first, (int)count).iterator();
+ }
+ }
+
+ @Override
+ public long size() {
+ DepotPage page = (DepotPage) getPage();
+
+ if (getPullRequest() != null) {
+ return getPullRequest().getCodeComments().size();
+ } else {
+ EntityCriteria<CodeComment> criteria = EntityCriteria.of(CodeComment.class);
+ criteria.add(Restrictions.eq("depot", page.getDepot()));
+ filterOptionModel.getObject().fill(criteria);
+ criteria.addOrder(Order.desc("id"));
+ return GitPlex.getInstance(Dao.class).count(criteria);
+ }
+ }
+
+ @Override
+ public IModel<CodeComment> model(CodeComment object) {
+ Long commentId = object.getId();
+ return new LoadableDetachableModel<CodeComment>() {
+
+ @Override
+ protected CodeComment load() {
+ return GitPlex.getInstance(CodeCommentManager.class).load(commentId);
+ }
+
+ };
+ }
+
+ };
+ DataTable<CodeComment, Void> dataTable = new DataTable<>("comments", columns,
+ dataProvider, getPullRequest()!=null?Integer.MAX_VALUE:Constants.DEFAULT_PAGE_SIZE);
+ dataTable.addBottomToolbar(new NoRecordsToolbar(dataTable));
+ dataTable.addBottomToolbar(new NavigationToolbar(dataTable));
+ add(dataTable);
+ }
+
+ @Override
+ protected void onDetach() {
+ filterOptionModel.detach();
+ super.onDetach();
+ }
+
+ @Override
+ public void renderHead(IHeaderResponse response) {
+ super.renderHead(response);
+ response.render(CssHeaderItem.forReference(new CssResourceReference(
+ CodeCommentListPanel.class, "code-comment-list.css")));
+ }
+
+ @Nullable
+ protected abstract PullRequest getPullRequest();
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.html
index 98153c0113..3afa3bfc3d 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.html
@@ -24,10 +24,27 @@
</div>
</div>
</wicket:fragment>
- <wicket:fragment wicket:id="editFrag">
+ <wicket:fragment wicket:id="commentEditFrag">
<form wicket:id="form" class="leave-confirm">
<div wicket:id="feedback" class="feedback"></div>
- <textarea wicket:id="input" rows="10" class="form-control focusable"></textarea>
+ <div class="form-group">
+ <label>Title</label>
+ <input wicket:id="title" class="form-control focusable"></input>
+ </div>
+ <div class="form-group">
+ <label>Content</label>
+ <textarea wicket:id="content" rows="10" class="form-control focusable"></textarea>
+ </div>
+ <div class="actions">
+ <button wicket:id="save" class="btn btn-sm btn-primary dirty-aware">Save</button>
+ <button wicket:id="cancel" class="btn btn-sm btn-default">Cancel</button>
+ </div>
+ </form>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="replyEditFrag">
+ <form wicket:id="form" class="leave-confirm">
+ <div wicket:id="feedback" class="feedback"></div>
+ <textarea wicket:id="content" rows="10" class="form-control focusable"></textarea>
<div class="actions">
<button wicket:id="save" class="btn btn-sm btn-primary dirty-aware">Save</button>
<button wicket:id="cancel" class="btn btn-sm btn-default">Cancel</button>
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 020c4b7acb..4577d654e2 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
@@ -14,6 +14,7 @@ import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.GenericPanel;
@@ -143,10 +144,14 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
@Override
public void onClick(AjaxRequestTarget target) {
- Fragment fragment = new Fragment(commentContainer.getId(), "editFrag", CodeCommentPanel.this);
+ Fragment fragment = new Fragment(commentContainer.getId(), "commentEditFrag", CodeCommentPanel.this);
Form<?> form = new Form<Void>("form");
form.setOutputMarkupId(true);
- CommentInput input = new CommentInput("input", Model.of(getComment().getContent())) {
+
+ TextField<String> titleInput = new TextField<String>("title", Model.of(getComment().getTitle()));
+ titleInput.setRequired(true);
+ form.add(titleInput);
+ CommentInput contentInput = new CommentInput("content", Model.of(getComment().getContent())) {
@Override
protected AttachmentSupport getAttachmentSupport() {
@@ -159,8 +164,8 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
}
};
- form.add(input);
- input.setRequired(true);
+ form.add(contentInput);
+ contentInput.setRequired(true);
NotificationPanel feedback = new NotificationPanel("feedback", form);
feedback.setOutputMarkupPlaceholderTag(true);
@@ -200,11 +205,13 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
CodeComment comment = getComment();
if (comment.getVersion() != lastVersion)
throw new StaleObjectStateException(CodeComment.class.getName(), comment.getId());
- comment.setContent(input.getModelObject());
+ comment.setTitle(titleInput.getModelObject());
+ comment.setContent(contentInput.getModelObject());
GitPlex.getInstance(CodeCommentManager.class).save(comment);
WebMarkupContainer commentContainer = newCommentContainer();
fragment.replaceWith(commentContainer);
target.add(commentContainer);
+ onSaveComment(target, comment);
} catch (StaleObjectStateException e) {
error("Some one changed the content you are editing. Reload the page and try again.");
target.add(feedback);
@@ -342,9 +349,9 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
@Override
public void onClick(AjaxRequestTarget target) {
- Fragment fragment = new Fragment(replyContainer.getId(), "editFrag", CodeCommentPanel.this);
+ Fragment fragment = new Fragment(replyContainer.getId(), "replyEditFrag", CodeCommentPanel.this);
Form<?> form = new Form<Void>("form");
- CommentInput input = new CommentInput("input", Model.of(getReply(replyId).getContent())) {
+ CommentInput contentInput = new CommentInput("content", Model.of(getReply(replyId).getContent())) {
@Override
protected AttachmentSupport getAttachmentSupport() {
@@ -357,8 +364,8 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
}
};
- form.add(input);
- input.setRequired(true);
+ form.add(contentInput);
+ contentInput.setRequired(true);
NotificationPanel feedback = new NotificationPanel("feedback", form);
feedback.setOutputMarkupPlaceholderTag(true);
@@ -398,7 +405,7 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
CodeCommentReply reply = getReply(replyId);
if (reply.getVersion() != lastVersion)
throw new StaleObjectStateException(CodeComment.class.getName(), reply.getId());
- reply.setContent(input.getModelObject());
+ reply.setContent(contentInput.getModelObject());
GitPlex.getInstance(CodeCommentReplyManager.class).save(reply);
WebMarkupContainer replyContainer = newReplyContainer(componentId, replyId);
fragment.replaceWith(replyContainer);
@@ -460,9 +467,9 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
@Override
public void onClick(AjaxRequestTarget target) {
- Fragment fragment = new Fragment(addReplyContainer.getId(), "editFrag", CodeCommentPanel.this);
+ Fragment fragment = new Fragment(addReplyContainer.getId(), "replyEditFrag", CodeCommentPanel.this);
Form<?> form = new Form<Void>("form");
- CommentInput input = new CommentInput("input", Model.of("")) {
+ CommentInput contentInput = new CommentInput("content", Model.of("")) {
@Override
protected AttachmentSupport getAttachmentSupport() {
@@ -475,10 +482,10 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
}
};
- form.add(input);
- input.setRequired(true);
+ form.add(contentInput);
+ contentInput.setRequired(true);
- NotificationPanel feedback = new NotificationPanel("feedback", input);
+ NotificationPanel feedback = new NotificationPanel("feedback", contentInput);
feedback.setOutputMarkupPlaceholderTag(true);
form.add(feedback);
@@ -514,7 +521,7 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
CodeCommentReply reply = new CodeCommentReply();
reply.setComment(getComment());
reply.setUser(SecurityUtils.getAccount());
- reply.setContent(input.getModelObject());
+ reply.setContent(contentInput.getModelObject());
reply.setCompareContext(getCompareContext());
GitPlex.getInstance(CodeCommentReplyManager.class).save(reply);
@@ -578,5 +585,7 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {
protected abstract void onCommentDeleted(AjaxRequestTarget target);
+ protected abstract void onSaveComment(AjaxRequestTarget target, CodeComment comment);
+
protected abstract CompareContext getCompareContext();
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/code-comment-list.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/code-comment-list.css
new file mode 100644
index 0000000000..e61b121f25
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/code-comment-list.css
@@ -0,0 +1,47 @@
+.code-comments td.filter {
+ width: 25%;
+ border: 1px solid #DDD;
+}
+.code-comments td.filter>.head {
+ font-size: 16px;
+ border-bottom: 1px solid #DDD;
+ padding: 8px 12px;
+ background: #F2F2F2;
+}
+.code-comments td.filter>.body>.shortcuts {
+ margin-bottom: 12px;
+}
+.code-comments td.filter>.body {
+ padding: 12px;
+}
+.code-comments td.spacing {
+ width: 20px;
+}
+.code-comments td.result {
+ border: 1px solid #DDD;
+ white-space: nowrap;
+ overflow: hidden;
+}
+.code-comments td.result a {
+ display: block;
+ text-decoration: none;
+ color: #999;
+ font-size: 12px;
+ padding: 8px;
+}
+.code-comments td.result a:hover {
+ background: #F2F2F2;
+}
+.code-comments td.result a .title {
+ font-weight: bold;
+ font-size: 14px;
+ color: #444;
+ text-overflow: ellipsis;
+}
+.code-comments td.result a .user, .code-comments td.result a .what {
+ font-weight: bold;
+ color: #666;
+}
+.code-comments td.result .second-line, .code-comments td.result .third-line {
+ margin-top: 2px;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/code-comment.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/code-comment.css
index 20967a6d3c..4ee9cfd1a0 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/code-comment.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/code-comment.css
@@ -1,3 +1,7 @@
+.code-comment .md-preview {
+ font-size: inherit;
+ line-height: inherit;
+}
.code-comment>.post {
border-bottom: 1px solid #EEE;
position: relative;
@@ -17,7 +21,6 @@
padding-left: 40px;
}
.code-comment>.post>.detail>.head .author-name {
- font-size: 14px;
color: #999;
}
.code-comment>.post>.detail>.head .author-name:hover {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html
index 4118818090..0557d7f2f6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html
@@ -3,12 +3,15 @@
<div wicket:id="comment" class="comment">
<div class="ui-resizable-handle ui-resizable-e"></div>
<div class="content">
- <div class="head clearfix">
- <span class="pull-left">Comment</span>
- <a wicket:id="close" class="pull-right close" title="Hide comment"><i class="fa fa-times"></i></a>
- <a wicket:id="locate" class="pull-right locate close" title="Locate marked text of this comment"><i class="fa fa-hand-o-right"></i></a>
- <a wicket:id="permanent" class="pull-right permanent close" title="Permanent link of this comment"><i class="fa fa-link"></i></a>
- <a wicket:id="context" class="pull-right context close" title="Show this comment by comparing with specified revision"><i class="fa fa-ext fa-file-diff"></i></a>
+ <div class="head">
+ <div wicket:id="title" class="title"></div>
+ <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="close" class="pull-left close" title="Hide comment"><i class="fa fa-times"></i></a>
+ <a wicket:id="resolve" class="pull-right resolve"><i class="fa fa-check-circle"></i></a>
+ </div>
</div>
<div wicket:id="body" class="body"></div>
</div>
@@ -32,7 +35,14 @@
<wicket:fragment wicket:id="newCommentFrag">
<form wicket:id="form" class="new-comment leave-confirm">
<div wicket:id="feedback" class="feedback"></div>
- <textarea wicket:id="input" rows="10" class="form-control focusable"></textarea>
+ <div class="form-group">
+ <label>Title</label>
+ <input wicket:id="title" class="form-control focusable"></input>
+ </div>
+ <div class="form-group">
+ <label>Content</label>
+ <textarea wicket:id="content" rows="10" class="form-control focusable"></textarea>
+ </div>
<div class="actions">
<button wicket:id="save" class="btn btn-sm btn-primary dirty-aware">Save</button>
<button wicket:id="cancel" class="btn btn-sm btn-default">Cancel</button>
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 e6f2ec71bf..24dbf21058 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
@@ -23,12 +23,15 @@ import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.markup.html.repeater.tree.ITreeProvider;
import org.apache.wicket.extensions.markup.html.repeater.tree.NestedTree;
import org.apache.wicket.extensions.markup.html.repeater.tree.theme.HumanTheme;
+import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.markup.html.panel.Fragment;
@@ -261,8 +264,31 @@ public class SourceViewPanel extends BlobViewPanel {
}
};
+ commentContainer.add(new Label("title", new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ CodeComment comment = context.getOpenComment();
+ return comment!=null?comment.getTitle():"";
+ }
+
+ }) {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(context.getOpenComment() != null);
+ }
+
+ });
commentContainer.add(new DropdownLink("context") {
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(context.getOpenComment() != null);
+ }
+
@Override
protected Component newContent(String id) {
return new RevisionSelector(id, new AbstractReadOnlyModel<Depot>() {
@@ -297,11 +323,14 @@ public class SourceViewPanel extends BlobViewPanel {
@Override
public void onClick(AjaxRequestTarget target) {
CodeComment comment = context.getOpenComment();
- if (comment != null)
- mark(target, comment.getMark(), true);
- else
- mark(target, (Mark) commentContainer.getDefaultModelObject(), true);
- context.onMark(target, context.getOpenComment().getMark());
+ Mark mark;
+ if (comment != null) {
+ mark = comment.getMark();
+ } else {
+ mark = (Mark) commentContainer.getDefaultModelObject();
+ }
+ mark(target, mark, true);
+ context.onMark(target, mark);
target.appendJavaScript(String.format("$('#%s').blur();", getMarkupId()));
}
@@ -360,6 +389,52 @@ public class SourceViewPanel extends BlobViewPanel {
});
+ commentContainer.add(new AjaxLink<Void>("resolve") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ CodeComment comment = context.getOpenComment();
+ setVisible(comment != null);
+ setEnabled(comment != null && SecurityUtils.canModify(comment));
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ CodeComment comment = context.getOpenComment();
+ if (comment != null) {
+ if (SecurityUtils.canModify(comment)) {
+ if (comment.isResolved()) {
+ tag.put("title", "Comment is currently resolved, click to mark as unresolved");
+ tag.put("class", "pull-right resolve resolved");
+ } else {
+ tag.put("title", "Comment is currently unresolved, click to mark as resolved");
+ tag.put("class", "pull-right resolve unresolved");
+ }
+ } else {
+ if (comment.isResolved()) {
+ tag.put("title", "Comment is currently resolved, contact comment owner or repository manager to change status of the comment");
+ tag.put("class", "pull-right resolve resolved");
+ } else {
+ tag.put("title", "Comment is currently unresolved, contact comment owner or repository manager to change status of the comment");
+ tag.put("class", "pull-right resolve unresolved");
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CodeComment comment = context.getOpenComment();
+ comment.setResolved(!comment.isResolved());
+ GitPlex.getInstance(CodeCommentManager.class).save(comment);
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.sourceview.onLayoutChange();");
+ }
+
+ });
+
commentContainer.setOutputMarkupPlaceholderTag(true);
if (context.getOpenComment() != null) {
IModel<CodeComment> commentModel = new LoadableDetachableModel<CodeComment>() {
@@ -382,6 +457,12 @@ public class SourceViewPanel extends BlobViewPanel {
protected CompareContext getCompareContext() {
return SourceViewPanel.this.getCompareContext();
}
+
+ @Override
+ protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.sourceview.onLayoutChange();");
+ }
};
commentContainer.add(commentPanel);
@@ -425,8 +506,13 @@ public class SourceViewPanel extends BlobViewPanel {
Form<?> form = new Form<Void>("form");
String uuid = UUID.randomUUID().toString();
- CommentInput input;
- form.add(input = new CommentInput("input", Model.of("")) {
+
+ 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() {
@@ -439,9 +525,9 @@ public class SourceViewPanel extends BlobViewPanel {
}
});
- input.setRequired(true);
+ contentInput.setRequired(true);
- NotificationPanel feedback = new NotificationPanel("feedback", input);
+ NotificationPanel feedback = new NotificationPanel("feedback", form);
feedback.setOutputMarkupPlaceholderTag(true);
form.add(feedback);
@@ -477,7 +563,8 @@ public class SourceViewPanel extends BlobViewPanel {
comment.setUUID(uuid);
comment.setCommit(context.getCommit().name());
comment.setPath(context.getBlobIdent().path);
- comment.setContent(input.getModelObject());
+ comment.setTitle(titleInput.getModelObject());
+ comment.setContent(contentInput.getModelObject());
comment.setDepot(context.getDepot());
comment.setUser(SecurityUtils.getAccount());
comment.setMark(mark);
@@ -506,6 +593,12 @@ public class SourceViewPanel extends BlobViewPanel {
protected CompareContext getCompareContext() {
return SourceViewPanel.this.getCompareContext();
}
+
+ @Override
+ protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.sourceview.onLayoutChange();");
+ }
};
commentContainer.replace(commentPanel);
@@ -547,6 +640,12 @@ public class SourceViewPanel extends BlobViewPanel {
protected CompareContext getCompareContext() {
return SourceViewPanel.this.getCompareContext();
}
+
+ @Override
+ protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.sourceview.onLayoutChange();");
+ }
};
commentContainer.replace(commentPanel);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.css
index ad38877964..3ea1afc427 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.css
@@ -5,23 +5,36 @@
background: white;
position: absolute;
padding-right: 4px;
+ border-left: 3px solid #F2F2F2;
top: 0;
left: 0;
}
+.source-view>.comment>.content>.head .title {
+ margin-bottom: 8px;
+}
.source-view>.comment>.content>.head .context {
- margin-right: 8px;
margin-top: -2px;
}
.source-view>.comment>.content>.head .context .fa-ext {
font-size: 16px;
}
.source-view>.comment>.content>.head .locate {
- margin-right: 8px;
font-size: 20px;
}
+.source-view>.comment>.content>.head .resolve {
+ margin-right: 0;
+ margin-top: -2px;
+ font-size: 20px;
+}
+.source-view>.comment>.content>.head .resolve.resolved {
+ color: #24BE10;
+}
+.source-view>.comment>.content>.head .resolve.unresolved {
+ color: #BBB;
+}
+
.source-view>.comment>.content>.head .permanent {
margin-top: 2px;
- margin-right: 8px;
font-size: 18px;
}
.source-view>.comment>.ui-resizable-handle {
@@ -34,12 +47,11 @@
top: 0;
}
.source-view>.comment>.content>.head {
- font-size: 16px;
- padding: 4px 8px;
+ font-weight: bold;
+ padding: 8px 12px;
background: #F2F2F2;
}
.source-view>.comment>.content>.body {
- font-size: 13px;
padding: 12px;
overflow: auto;
}
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 cc916f5513..68814cf571 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
@@ -44,12 +44,15 @@
<div wicket:id="comment" class="comment">
<div class="ui-resizable-handle ui-resizable-e"></div>
<div class="content">
- <div class="head clearfix">
- <span class="pull-left">Comment</span>
- <a wicket:id="close" class="pull-right close" title="Hide comment"><i class="fa fa-times"></i></a>
- <a wicket:id="locate" class="pull-right locate close" title="Locate marked text of this comment"><i class="fa fa-hand-o-right"></i></a>
- <a wicket:id="permanent" class="pull-right permanent close" title="Permanent link of this comment"><i class="fa fa-link"></i></a>
- <a wicket:id="context" class="pull-right context close" title="Show this comment by comparing with specified revision"><i class="fa fa-ext fa-file-diff"></i></a>
+ <div class="head">
+ <div wicket:id="title" class="title"></div>
+ <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="close" class="pull-left close" title="Hide comment"><i class="fa fa-times"></i></a>
+ <a wicket:id="resolve" class="pull-right resolve"><i class="fa fa-check-circle"></i></a>
+ </div>
</div>
<div wicket:id="body" class="body"></div>
</div>
@@ -65,7 +68,14 @@
<wicket:fragment wicket:id="newCommentFrag">
<form wicket:id="form" class="new-comment leave-confirm">
<div wicket:id="feedback" class="feedback"></div>
- <textarea wicket:id="input" rows="10" class="form-control focusable"></textarea>
+ <div class="form-group">
+ <label>Title</label>
+ <input wicket:id="title" class="form-control focusable"></input>
+ </div>
+ <div class="form-group">
+ <label>Content</label>
+ <textarea wicket:id="content" rows="10" class="form-control focusable"></textarea>
+ </div>
<div class="actions">
<button wicket:id="save" class="btn btn-sm btn-primary dirty-aware">Save</button>
<button wicket:id="cancel" class="btn btn-sm btn-default">Cancel</button>
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 9ee0fb23dc..bd6a67df90 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
@@ -25,6 +25,7 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
@@ -740,6 +741,12 @@ public class RevisionDiffPanel extends Panel {
protected CompareContext getCompareContext() {
return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommit());
}
+
+ @Override
+ protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
};
@@ -775,8 +782,12 @@ public class RevisionDiffPanel extends Panel {
Form<?> form = new Form<Void>("form");
String uuid = UUID.randomUUID().toString();
- CommentInput input;
- form.add(input = new CommentInput("input", Model.of("")) {
+
+ 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() {
@@ -789,9 +800,9 @@ public class RevisionDiffPanel extends Panel {
}
});
- input.setRequired(true);
+ contentInput.setRequired(true);
- NotificationPanel feedback = new NotificationPanel("feedback", input);
+ NotificationPanel feedback = new NotificationPanel("feedback", form);
feedback.setOutputMarkupPlaceholderTag(true);
form.add(feedback);
@@ -832,7 +843,8 @@ public class RevisionDiffPanel extends Panel {
comment.setMark(new Mark(mark.getBeginLine(), mark.getBeginChar(),
mark.getEndLine(), mark.getEndChar()));
comment.setCompareContext(getCompareContext(comment.getCommit()));
- comment.setContent(input.getModelObject());
+ comment.setTitle(titleInput.getModelObject());
+ comment.setContent(contentInput.getModelObject());
GitPlex.getInstance(CodeCommentManager.class).save(comment);
Long commentId = comment.getId();
@@ -856,6 +868,12 @@ public class RevisionDiffPanel extends Panel {
protected CompareContext getCompareContext() {
return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommit());
}
+
+ @Override
+ protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
};
commentContainer.replace(commentPanel);
@@ -960,8 +978,32 @@ public class RevisionDiffPanel extends Panel {
};
commentContainer.setOutputMarkupPlaceholderTag(true);
+ commentContainer.add(new Label("title", new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ CodeComment comment = getOpenComment();
+ return comment!=null?comment.getTitle():"";
+ }
+
+ }) {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(getOpenComment() != null);
+ }
+
+ });
+
commentContainer.add(new DropdownLink("context") {
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(getOpenComment() != null);
+ }
+
@Override
protected Component newContent(String id) {
return new RevisionSelector(id, new AbstractReadOnlyModel<Depot>() {
@@ -1074,6 +1116,52 @@ public class RevisionDiffPanel extends Panel {
});
+ commentContainer.add(new AjaxLink<Void>("resolve") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ CodeComment comment = getOpenComment();
+ setVisible(comment != null);
+ setEnabled(comment != null && SecurityUtils.canModify(comment));
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ CodeComment comment = getOpenComment();
+ if (comment != null) {
+ if (SecurityUtils.canModify(comment)) {
+ if (comment.isResolved()) {
+ tag.put("title", "Comment is currently resolved, click to mark as unresolved");
+ tag.put("class", "pull-right resolve resolved");
+ } else {
+ tag.put("title", "Comment is currently unresolved, click to mark as resolved");
+ tag.put("class", "pull-right resolve unresolved");
+ }
+ } else {
+ if (comment.isResolved()) {
+ tag.put("title", "Comment is currently resolved, contact comment owner or repository manager to change status of the comment");
+ tag.put("class", "pull-right resolve resolved");
+ } else {
+ tag.put("title", "Comment is currently unresolved, contact comment owner or repository manager to change status of the comment");
+ tag.put("class", "pull-right resolve unresolved");
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CodeComment comment = getOpenComment();
+ comment.setResolved(!comment.isResolved());
+ GitPlex.getInstance(CodeCommentManager.class).save(comment);
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
+
+ });
+
boolean locatable = false;
CodeComment comment = getOpenComment();
if (comment != null) {
@@ -1106,6 +1194,12 @@ public class RevisionDiffPanel extends Panel {
protected CompareContext getCompareContext() {
return RevisionDiffPanel.this.getCompareContext(commentModel.getObject().getCommit());
}
+
+ @Override
+ protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
+ target.add(commentContainer);
+ target.appendJavaScript("gitplex.revisionDiff.reposition();");
+ }
};
commentContainer.add(commentPanel);
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 8345e0dafb..9ece891519 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
@@ -84,44 +84,56 @@
.revision-diff>.body>.detail>.comment {
border: 1px solid #DDD;
margin-right: 12px;
- padding-right: 4px;
+ padding-right: 3px;
background: white;
position: absolute;
left: 0;
z-index: 1;
}
.revision-diff>.body>.detail>.comment>.content>.head .locate {
- margin-right: 8px;
font-size: 20px;
}
.revision-diff>.body>.detail>.comment>.content>.head .permanent {
margin-top: 2px;
- margin-right: 8px;
font-size: 18px;
}
.revision-diff>.body>.detail>.comment>.content>.head .context {
- margin-right: 8px;
margin-top: -2px;
}
.revision-diff>.body>.detail>.comment>.content>.head .context .fa-ext {
font-size: 16px;
}
+.revision-diff>.body>.detail>.comment>.content>.head .resolve {
+ margin-right: 0;
+ margin-top: -2px;
+ font-size: 20px;
+}
+.revision-diff>.body>.detail>.comment>.content>.head .resolve.resolved {
+ color: #24BE10;
+}
+.revision-diff>.body>.detail>.comment>.content>.head .resolve.unresolved {
+ color: #BBB;
+}
.revision-diff>.body>.detail>.comment>.ui-resizable-handle {
position: absolute;
background: #EEE url("vgrabber.png") no-repeat scroll right center;
cursor: e-resize;
- width: 4px;
+ width: 3px;
right: 0;
top: 0;
}
.revision-diff>.body>.detail>.comment>.content>.head {
- font-size: 16px;
- padding: 4px 8px;
+ font-weight: bold;
+ padding: 8px 12px;
background: #F2F2F2;
}
+.revision-diff>.body>.detail>.comment>.content>.head .title {
+ margin-bottom: 8px;
+}
.revision-diff>.body>.detail>.comment>.content>.body {
- font-size: 13px;
padding: 12px;
overflow: auto;
+ border-left: 3px solid #F2F2F2;
+ border-bottom: 3px solid #F2F2F2;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountEditSupport.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountEditSupport.java
index 6f3a6e0f42..d82c32ddd2 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountEditSupport.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountEditSupport.java
@@ -1,96 +1,97 @@
-package com.pmease.gitplex.web.editable.accountchoice;
-
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.model.IModel;
-import org.eclipse.jgit.util.StringUtils;
-
-import com.pmease.commons.wicket.editable.BeanContext;
-import com.pmease.commons.wicket.editable.DefaultPropertyDescriptor;
-import com.pmease.commons.wicket.editable.EditSupport;
-import com.pmease.commons.wicket.editable.EditableUtils;
-import com.pmease.commons.wicket.editable.NotDefinedLabel;
-import com.pmease.commons.wicket.editable.PropertyContext;
-import com.pmease.commons.wicket.editable.PropertyDescriptor;
-import com.pmease.commons.wicket.editable.PropertyEditor;
-import com.pmease.commons.wicket.editable.PropertyViewer;
-import com.pmease.gitplex.core.annotation.UserChoice;
-
-@SuppressWarnings("serial")
-public class AccountEditSupport implements EditSupport {
-
- @Override
- public BeanContext<?> getBeanEditContext(Class<?> beanClass, Set<String> excludeProperties) {
- return null;
- }
-
- @Override
- public PropertyContext<?> getPropertyEditContext(Class<?> beanClass, String propertyName) {
- PropertyDescriptor propertyDescriptor = new DefaultPropertyDescriptor(beanClass, propertyName);
- Method propertyGetter = propertyDescriptor.getPropertyGetter();
- if (propertyGetter.getAnnotation(UserChoice.class) != null) {
- if (List.class.isAssignableFrom(propertyGetter.getReturnType())
- && EditableUtils.getElementClass(propertyGetter.getGenericReturnType()) == String.class) {
- return new PropertyContext<List<String>>(propertyDescriptor) {
-
- @Override
- public PropertyViewer renderForView(String componentId, final IModel<List<String>> model) {
- return new PropertyViewer(componentId, this) {
-
- @Override
- protected Component newContent(String id, PropertyDescriptor propertyDescriptor) {
- List<String> userNames = model.getObject();
- if (userNames != null && !userNames.isEmpty()) {
- return new Label(id, StringUtils.join(userNames, ", " ));
- } else {
- return new NotDefinedLabel(id);
- }
- }
-
- };
- }
-
- @Override
- public PropertyEditor<List<String>> renderForEdit(String componentId, IModel<List<String>> model) {
- return new AccountMultiChoiceEditor(componentId, this, model);
- }
-
- };
- } else if (propertyGetter.getReturnType() == String.class) {
- return new PropertyContext<String>(propertyDescriptor) {
-
- @Override
- public PropertyViewer renderForView(String componentId, final IModel<String> model) {
- return new PropertyViewer(componentId, this) {
-
- @Override
- protected Component newContent(String id, PropertyDescriptor propertyDescriptor) {
- if (model.getObject() != null) {
- return new Label(id, model.getObject());
- } else {
- return new NotDefinedLabel(id);
- }
- }
-
- };
- }
-
- @Override
- public PropertyEditor<String> renderForEdit(String componentId, IModel<String> model) {
- return new AccountSingleChoiceEditor(componentId, this, model);
- }
-
- };
- } else {
- throw new RuntimeException("Annotation 'UserChoice' should be applied to property with type 'String' or 'List<String>'.");
- }
- } else {
- return null;
- }
- }
-
-}
+package com.pmease.gitplex.web.editable.accountchoice;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.IModel;
+import org.eclipse.jgit.util.StringUtils;
+
+import com.pmease.commons.wicket.editable.BeanContext;
+import com.pmease.commons.wicket.editable.DefaultPropertyDescriptor;
+import com.pmease.commons.wicket.editable.EditSupport;
+import com.pmease.commons.wicket.editable.EditableUtils;
+import com.pmease.commons.wicket.editable.NotDefinedLabel;
+import com.pmease.commons.wicket.editable.PropertyContext;
+import com.pmease.commons.wicket.editable.PropertyDescriptor;
+import com.pmease.commons.wicket.editable.PropertyEditor;
+import com.pmease.commons.wicket.editable.PropertyViewer;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+
+@SuppressWarnings("serial")
+public class AccountEditSupport implements EditSupport {
+
+ @Override
+ public BeanContext<?> getBeanEditContext(Class<?> beanClass, Set<String> excludeProperties) {
+ return null;
+ }
+
+ @Override
+ public PropertyContext<?> getPropertyEditContext(Class<?> beanClass, String propertyName) {
+ PropertyDescriptor propertyDescriptor = new DefaultPropertyDescriptor(beanClass, propertyName);
+ Method propertyGetter = propertyDescriptor.getPropertyGetter();
+ AccountChoice accountChoice = propertyGetter.getAnnotation(AccountChoice.class);
+ if (accountChoice != null) {
+ if (List.class.isAssignableFrom(propertyGetter.getReturnType())
+ && EditableUtils.getElementClass(propertyGetter.getGenericReturnType()) == String.class) {
+ return new PropertyContext<List<String>>(propertyDescriptor) {
+
+ @Override
+ public PropertyViewer renderForView(String componentId, final IModel<List<String>> model) {
+ return new PropertyViewer(componentId, this) {
+
+ @Override
+ protected Component newContent(String id, PropertyDescriptor propertyDescriptor) {
+ List<String> userNames = model.getObject();
+ if (userNames != null && !userNames.isEmpty()) {
+ return new Label(id, StringUtils.join(userNames, ", " ));
+ } else {
+ return new NotDefinedLabel(id);
+ }
+ }
+
+ };
+ }
+
+ @Override
+ public PropertyEditor<List<String>> renderForEdit(String componentId, IModel<List<String>> model) {
+ return new AccountMultiChoiceEditor(componentId, this, model, accountChoice.organization());
+ }
+
+ };
+ } else if (propertyGetter.getReturnType() == String.class) {
+ return new PropertyContext<String>(propertyDescriptor) {
+
+ @Override
+ public PropertyViewer renderForView(String componentId, final IModel<String> model) {
+ return new PropertyViewer(componentId, this) {
+
+ @Override
+ protected Component newContent(String id, PropertyDescriptor propertyDescriptor) {
+ if (model.getObject() != null) {
+ return new Label(id, model.getObject());
+ } else {
+ return new NotDefinedLabel(id);
+ }
+ }
+
+ };
+ }
+
+ @Override
+ public PropertyEditor<String> renderForEdit(String componentId, IModel<String> model) {
+ return new AccountSingleChoiceEditor(componentId, this, model, accountChoice.organization());
+ }
+
+ };
+ } else {
+ throw new RuntimeException("Annotation 'UserChoice' should be applied to property with type 'String' or 'List<String>'.");
+ }
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountMultiChoiceEditor.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountMultiChoiceEditor.java
index f2ec5ea58e..d9e3ee70be 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountMultiChoiceEditor.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountMultiChoiceEditor.java
@@ -1,68 +1,72 @@
-package com.pmease.gitplex.web.editable.accountchoice;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.util.convert.ConversionException;
-
-import com.pmease.commons.wicket.editable.ErrorContext;
-import com.pmease.commons.wicket.editable.PathSegment;
-import com.pmease.commons.wicket.editable.PropertyDescriptor;
-import com.pmease.commons.wicket.editable.PropertyEditor;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.manager.AccountManager;
-import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
-import com.pmease.gitplex.web.component.accountchoice.AccountMultiChoice;
-
-@SuppressWarnings("serial")
-public class AccountMultiChoiceEditor extends PropertyEditor<List<String>> {
-
- private AccountMultiChoice input;
-
- public AccountMultiChoiceEditor(String id, PropertyDescriptor propertyDescriptor, IModel<List<String>> propertyModel) {
- super(id, propertyDescriptor, propertyModel);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- List<Account> accounts = new ArrayList<>();
- if (getModelObject() != null) {
- AccountManager accountManager = GitPlex.getInstance(AccountManager.class);
- for (String accountName: getModelObject()) {
- Account account = accountManager.findByName(accountName);
- if (account != null)
- accounts.add(account);
- }
- }
-
- input = new AccountMultiChoice("input", new Model((Serializable)accounts), new AccountChoiceProvider());
- input.setConvertEmptyInputStringToNull(true);
-
- add(input);
- }
-
- @Override
- public ErrorContext getErrorContext(PathSegment pathSegment) {
- return null;
- }
-
- @Override
- protected List<String> convertInputToValue() throws ConversionException {
- List<String> accountNames = new ArrayList<>();
- Collection<Account> accounts = input.getConvertedInput();
- if (accounts != null) {
- for (Account account: accounts)
- accountNames.add(account.getName());
- }
- return accountNames;
- }
-
-}
+package com.pmease.gitplex.web.editable.accountchoice;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.convert.ConversionException;
+
+import com.pmease.commons.wicket.editable.ErrorContext;
+import com.pmease.commons.wicket.editable.PathSegment;
+import com.pmease.commons.wicket.editable.PropertyDescriptor;
+import com.pmease.commons.wicket.editable.PropertyEditor;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.manager.AccountManager;
+import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
+import com.pmease.gitplex.web.component.accountchoice.AccountMultiChoice;
+
+@SuppressWarnings("serial")
+public class AccountMultiChoiceEditor extends PropertyEditor<List<String>> {
+
+ private AccountMultiChoice input;
+
+ private final boolean organization;
+
+ public AccountMultiChoiceEditor(String id, PropertyDescriptor propertyDescriptor,
+ IModel<List<String>> propertyModel, boolean organization) {
+ super(id, propertyDescriptor, propertyModel);
+ this.organization = organization;
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ List<Account> accounts = new ArrayList<>();
+ if (getModelObject() != null) {
+ AccountManager accountManager = GitPlex.getInstance(AccountManager.class);
+ for (String accountName: getModelObject()) {
+ Account account = accountManager.findByName(accountName);
+ if (account != null)
+ accounts.add(account);
+ }
+ }
+
+ input = new AccountMultiChoice("input", new Model((Serializable)accounts), new AccountChoiceProvider(organization));
+ input.setConvertEmptyInputStringToNull(true);
+
+ add(input);
+ }
+
+ @Override
+ public ErrorContext getErrorContext(PathSegment pathSegment) {
+ return null;
+ }
+
+ @Override
+ protected List<String> convertInputToValue() throws ConversionException {
+ List<String> accountNames = new ArrayList<>();
+ Collection<Account> accounts = input.getConvertedInput();
+ if (accounts != null) {
+ for (Account account: accounts)
+ accountNames.add(account.getName());
+ }
+ return accountNames;
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountSingleChoiceEditor.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountSingleChoiceEditor.java
index 624f878497..24675bcfa2 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountSingleChoiceEditor.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/accountchoice/AccountSingleChoiceEditor.java
@@ -1,59 +1,63 @@
-package com.pmease.gitplex.web.editable.accountchoice;
-
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.util.convert.ConversionException;
-
-import com.pmease.commons.wicket.editable.ErrorContext;
-import com.pmease.commons.wicket.editable.PathSegment;
-import com.pmease.commons.wicket.editable.PropertyDescriptor;
-import com.pmease.commons.wicket.editable.PropertyEditor;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.manager.AccountManager;
-import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
-import com.pmease.gitplex.web.component.accountchoice.AccountSingleChoice;
-
-@SuppressWarnings("serial")
-public class AccountSingleChoiceEditor extends PropertyEditor<String> {
-
- private AccountSingleChoice input;
-
- public AccountSingleChoiceEditor(String id, PropertyDescriptor propertyDescriptor, IModel<String> propertyModel) {
- super(id, propertyDescriptor, propertyModel);
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- Account account;
- if (getModelObject() != null)
- account = GitPlex.getInstance(AccountManager.class).findByName(getModelObject());
- else
- account = null;
-
- input = new AccountSingleChoice("input", Model.of(account), new AccountChoiceProvider());
- input.setConvertEmptyInputStringToNull(true);
-
- // add this to control allowClear flag of select2
- input.setRequired(propertyDescriptor.isPropertyRequired());
-
- add(input);
- }
-
- @Override
- public ErrorContext getErrorContext(PathSegment pathSegment) {
- return null;
- }
-
- @Override
- protected String convertInputToValue() throws ConversionException {
- Account account = input.getConvertedInput();
- if (account != null)
- return account.getName();
- else
- return null;
- }
-
-}
+package com.pmease.gitplex.web.editable.accountchoice;
+
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.convert.ConversionException;
+
+import com.pmease.commons.wicket.editable.ErrorContext;
+import com.pmease.commons.wicket.editable.PathSegment;
+import com.pmease.commons.wicket.editable.PropertyDescriptor;
+import com.pmease.commons.wicket.editable.PropertyEditor;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.manager.AccountManager;
+import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
+import com.pmease.gitplex.web.component.accountchoice.AccountSingleChoice;
+
+@SuppressWarnings("serial")
+public class AccountSingleChoiceEditor extends PropertyEditor<String> {
+
+ private AccountSingleChoice input;
+
+ private boolean organization;
+
+ public AccountSingleChoiceEditor(String id, PropertyDescriptor propertyDescriptor,
+ IModel<String> propertyModel, boolean organization) {
+ super(id, propertyDescriptor, propertyModel);
+ this.organization = organization;
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ Account account;
+ if (getModelObject() != null)
+ account = GitPlex.getInstance(AccountManager.class).findByName(getModelObject());
+ else
+ account = null;
+
+ input = new AccountSingleChoice("input", Model.of(account), new AccountChoiceProvider(organization));
+ input.setConvertEmptyInputStringToNull(true);
+
+ // add this to control allowClear flag of select2
+ input.setRequired(propertyDescriptor.isPropertyRequired());
+
+ add(input);
+ }
+
+ @Override
+ public ErrorContext getErrorContext(PathSegment pathSegment) {
+ return null;
+ }
+
+ @Override
+ protected String convertInputToValue() throws ConversionException {
+ Account account = input.getConvertedInput();
+ if (account != null)
+ return account.getName();
+ else
+ return null;
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileChoiceEditor.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileChoiceEditor.html
new file mode 100644
index 0000000000..3d9168eeba
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileChoiceEditor.html
@@ -0,0 +1,3 @@
+<wicket:panel>
+ <input wicket:id="input" autocomplete="off" spellcheck="false" class="focusable form-control"></input>
+</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileChoiceEditor.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileChoiceEditor.java
new file mode 100644
index 0000000000..68a06d8d61
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileChoiceEditor.java
@@ -0,0 +1,103 @@
+package com.pmease.gitplex.web.editable.filechoice;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.convert.ConversionException;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.pmease.commons.antlr.codeassist.InputCompletion;
+import com.pmease.commons.antlr.codeassist.InputStatus;
+import com.pmease.commons.antlr.codeassist.InputSuggestion;
+import com.pmease.commons.util.Range;
+import com.pmease.commons.util.ReflectionUtils;
+import com.pmease.commons.wicket.behavior.inputassist.InputAssistBehavior;
+import com.pmease.commons.wicket.editable.ErrorContext;
+import com.pmease.commons.wicket.editable.PathSegment;
+import com.pmease.commons.wicket.editable.PropertyDescriptor;
+import com.pmease.commons.wicket.editable.PropertyEditor;
+import com.pmease.gitplex.core.annotation.FileChoice;
+import com.pmease.gitplex.web.util.SuggestionUtils;
+
+@SuppressWarnings("serial")
+public class FileChoiceEditor extends PropertyEditor<String> {
+
+ private final List<String> choices = new ArrayList<>();
+
+ private TextField<String> input;
+
+ @SuppressWarnings("unchecked")
+ public FileChoiceEditor(String id, PropertyDescriptor propertyDescriptor, IModel<String> propertyModel) {
+ super(id, propertyDescriptor, propertyModel);
+
+ FileChoice fileChoice = propertyDescriptor.getPropertyGetter().getAnnotation(FileChoice.class);
+ Preconditions.checkNotNull(fileChoice);
+ for (String each: (List<String>)ReflectionUtils
+ .invokeStaticMethod(propertyDescriptor.getBeanClass(), fileChoice.value())) {
+ choices.add(each);
+ }
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ input = new TextField<String>("input", Model.of(getModelObject()));
+
+ input.add(new InputAssistBehavior() {
+
+ @Override
+ protected List<InputCompletion> getSuggestions(InputStatus inputStatus, int count) {
+ List<InputCompletion> completions = new ArrayList<>();
+ for (InputSuggestion suggestion: SuggestionUtils.suggestPath(choices,
+ inputStatus.getContentBeforeCaret().trim(), count)) {
+ int caret = suggestion.getCaret();
+ if (caret == -1)
+ caret = suggestion.getContent().length();
+ InputCompletion completion = new InputCompletion(0, inputStatus.getContent().length(),
+ suggestion.getContent(), caret, suggestion.getLabel(),
+ null, suggestion.getMatchRange());
+ completions.add(completion);
+ }
+ return completions;
+ }
+
+ @Override
+ protected List<String> getHints(InputStatus inputStatus) {
+ return Lists.newArrayList("Use * to match any string in the path");
+ }
+
+ @Override
+ protected List<Range> getErrors(String inputContent) {
+ return null;
+ }
+
+ @Override
+ protected int getAnchor(String content) {
+ for (int i=0; i<content.length(); i++) {
+ if (!Character.isWhitespace(content.charAt(i)))
+ return i;
+ }
+ return content.length();
+ }
+
+ });
+
+ add(input);
+ }
+
+ @Override
+ public ErrorContext getErrorContext(PathSegment pathSegment) {
+ return null;
+ }
+
+ @Override
+ protected String convertInputToValue() throws ConversionException {
+ return input.getConvertedInput();
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileEditSupport.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileEditSupport.java
new file mode 100644
index 0000000000..b63ce5906c
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/filechoice/FileEditSupport.java
@@ -0,0 +1,67 @@
+package com.pmease.gitplex.web.editable.filechoice;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.IModel;
+
+import com.pmease.commons.wicket.editable.BeanContext;
+import com.pmease.commons.wicket.editable.DefaultPropertyDescriptor;
+import com.pmease.commons.wicket.editable.EditSupport;
+import com.pmease.commons.wicket.editable.NotDefinedLabel;
+import com.pmease.commons.wicket.editable.PropertyContext;
+import com.pmease.commons.wicket.editable.PropertyDescriptor;
+import com.pmease.commons.wicket.editable.PropertyEditor;
+import com.pmease.commons.wicket.editable.PropertyViewer;
+import com.pmease.gitplex.core.annotation.FileChoice;
+
+@SuppressWarnings("serial")
+public class FileEditSupport implements EditSupport {
+
+ @Override
+ public BeanContext<?> getBeanEditContext(Class<?> beanClass, Set<String> excludeProperties) {
+ return null;
+ }
+
+ @Override
+ public PropertyContext<?> getPropertyEditContext(Class<?> beanClass, String propertyName) {
+ PropertyDescriptor propertyDescriptor = new DefaultPropertyDescriptor(beanClass, propertyName);
+ Method propertyGetter = propertyDescriptor.getPropertyGetter();
+ FileChoice fileChoice = propertyGetter.getAnnotation(FileChoice.class);
+ if (fileChoice != null) {
+ if (propertyGetter.getReturnType() == String.class) {
+ return new PropertyContext<String>(propertyDescriptor) {
+
+ @Override
+ public PropertyViewer renderForView(String componentId, final IModel<String> model) {
+ return new PropertyViewer(componentId, this) {
+
+ @Override
+ protected Component newContent(String id, PropertyDescriptor propertyDescriptor) {
+ if (model.getObject() != null) {
+ return new Label(id, model.getObject());
+ } else {
+ return new NotDefinedLabel(id);
+ }
+ }
+
+ };
+ }
+
+ @Override
+ public PropertyEditor<String> renderForEdit(String componentId, IModel<String> model) {
+ return new FileChoiceEditor(componentId, this, model);
+ }
+
+ };
+ } else {
+ throw new RuntimeException("Annotation 'FileChoice' should be applied to property with type 'String'.");
+ }
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java
index df30b18848..80639cb9c5 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java
@@ -40,6 +40,7 @@ import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
import com.pmease.gitplex.web.page.depot.overview.DepotOverviewPage;
import com.pmease.gitplex.web.page.depot.pullrequest.newrequest.NewRequestPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.changes.RequestChangesPage;
+import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.codecomments.CodeCommentsPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.integrationpreview.IntegrationPreviewPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview.RequestOverviewPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.updates.RequestUpdatesPage;
@@ -173,6 +174,8 @@ public class UrlMapper extends CompoundRequestMapper {
"${account}/${depot}/pulls/${request}/overview", RequestOverviewPage.class));
add(new DepotMapper(
"${account}/${depot}/pulls/${request}/updates", RequestUpdatesPage.class));
+ add(new DepotMapper(
+ "${account}/${depot}/pulls/${request}/code-comments", CodeCommentsPage.class));
add(new DepotMapper(
"${account}/${depot}/pulls/${request}/changes", RequestChangesPage.class));
add(new DepotMapper(
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/members/NonMemberChoiceProvider.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/members/NonMemberChoiceProvider.java
index 126c1e2781..215c450e41 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/members/NonMemberChoiceProvider.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/members/NonMemberChoiceProvider.java
@@ -1,63 +1,64 @@
-package com.pmease.gitplex.web.page.account.members;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.wicket.model.IModel;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.MatchMode;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Restrictions;
-
-import com.pmease.commons.hibernate.dao.EntityCriteria;
-import com.pmease.commons.wicket.component.select2.ResponseFiller;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.entity.OrganizationMembership;
-import com.pmease.gitplex.core.manager.AccountManager;
-import com.pmease.gitplex.web.Constants;
-import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
-import com.vaynberg.wicket.select2.Response;
-
-public class NonMemberChoiceProvider extends AccountChoiceProvider {
-
- private static final long serialVersionUID = 1L;
-
- private final IModel<Account> organizationModel;
-
- public NonMemberChoiceProvider(IModel<Account> organizationModel) {
- this.organizationModel = organizationModel;
- }
-
- @Override
- public void query(String term, int page, Response<Account> response) {
- AccountManager accountManager = GitPlex.getInstance(AccountManager.class);
- Criterion criterion = Restrictions.and(
- Restrictions.or(
- Restrictions.ilike("name", term, MatchMode.ANYWHERE),
- Restrictions.ilike("fullName", term, MatchMode.ANYWHERE)),
- Restrictions.eq("organization", false));
-
- Set<Account> members = new HashSet<>();
- for (OrganizationMembership membership: organizationModel.getObject().getOrganizationMembers())
- members.add(membership.getUser());
-
- List<Account> nonMembers = new ArrayList<>();
- EntityCriteria<Account> criteria = accountManager.newCriteria();
- for (Account user: accountManager.query(criteria.add(criterion).addOrder(Order.asc("name")), 0, 0)) {
- if (!members.contains(user))
- nonMembers.add(user);
- }
-
- new ResponseFiller<Account>(response).fill(nonMembers, page, Constants.DEFAULT_PAGE_SIZE);
- }
-
- @Override
- public void detach() {
- organizationModel.detach();
- super.detach();
- }
-
+package com.pmease.gitplex.web.page.account.members;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.wicket.model.IModel;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.MatchMode;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.commons.wicket.component.select2.ResponseFiller;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.entity.OrganizationMembership;
+import com.pmease.gitplex.core.manager.AccountManager;
+import com.pmease.gitplex.web.Constants;
+import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
+import com.vaynberg.wicket.select2.Response;
+
+public class NonMemberChoiceProvider extends AccountChoiceProvider {
+
+ private static final long serialVersionUID = 1L;
+
+ private final IModel<Account> organizationModel;
+
+ public NonMemberChoiceProvider(IModel<Account> organizationModel) {
+ super(false);
+ this.organizationModel = organizationModel;
+ }
+
+ @Override
+ public void query(String term, int page, Response<Account> response) {
+ AccountManager accountManager = GitPlex.getInstance(AccountManager.class);
+ Criterion criterion = Restrictions.and(
+ Restrictions.or(
+ Restrictions.ilike("name", term, MatchMode.ANYWHERE),
+ Restrictions.ilike("fullName", term, MatchMode.ANYWHERE)),
+ Restrictions.eq("organization", false));
+
+ Set<Account> members = new HashSet<>();
+ for (OrganizationMembership membership: organizationModel.getObject().getOrganizationMembers())
+ members.add(membership.getUser());
+
+ List<Account> nonMembers = new ArrayList<>();
+ EntityCriteria<Account> criteria = accountManager.newCriteria();
+ for (Account user: accountManager.query(criteria.add(criterion).addOrder(Order.asc("name")), 0, 0)) {
+ if (!members.contains(user))
+ nonMembers.add(user);
+ }
+
+ new ResponseFiller<Account>(response).fill(nonMembers, page, Constants.DEFAULT_PAGE_SIZE);
+ }
+
+ @Override
+ public void detach() {
+ organizationModel.detach();
+ super.detach();
+ }
+
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/teams/MemberChoiceProvider.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/teams/MemberChoiceProvider.java
index 9bf6799e7d..06985e4c54 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/teams/MemberChoiceProvider.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/teams/MemberChoiceProvider.java
@@ -1,56 +1,57 @@
-package com.pmease.gitplex.web.page.account.teams;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.wicket.model.IModel;
-
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.entity.OrganizationMembership;
-import com.pmease.gitplex.web.Constants;
-import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
-import com.vaynberg.wicket.select2.Response;
-
-public class MemberChoiceProvider extends AccountChoiceProvider {
-
- private static final long serialVersionUID = 1L;
-
- private final IModel<Account> organizationModel;
-
- public MemberChoiceProvider(IModel<Account> organizationModel) {
- this.organizationModel = organizationModel;
- }
-
- @Override
- public void query(String term, int page, Response<Account> response) {
- List<Account> members = new ArrayList<>();
- term = term.toLowerCase();
- for (OrganizationMembership membership: organizationModel.getObject().getOrganizationMembers()) {
- Account user = membership.getUser();
- if (user.getName().toLowerCase().contains(term)
- || user.getFullName()!=null && user.getFullName().toLowerCase().contains(term)) {
- members.add(user);
- }
- }
- members.sort((user1, user2) -> user1.getName().compareTo(user2.getName()));
-
- int from = page * Constants.DEFAULT_PAGE_SIZE;
- int to = from + Constants.DEFAULT_PAGE_SIZE;
-
- if (to > members.size()) {
- to = members.size();
- }
- if (from > to) {
- from = to;
- }
- response.addAll(members.subList(from, to));
- response.setHasMore(to<members.size());
- }
-
- @Override
- public void detach() {
- organizationModel.detach();
- super.detach();
- }
-
+package com.pmease.gitplex.web.page.account.teams;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wicket.model.IModel;
+
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.entity.OrganizationMembership;
+import com.pmease.gitplex.web.Constants;
+import com.pmease.gitplex.web.component.accountchoice.AccountChoiceProvider;
+import com.vaynberg.wicket.select2.Response;
+
+public class MemberChoiceProvider extends AccountChoiceProvider {
+
+ private static final long serialVersionUID = 1L;
+
+ private final IModel<Account> organizationModel;
+
+ public MemberChoiceProvider(IModel<Account> organizationModel) {
+ super(false);
+ this.organizationModel = organizationModel;
+ }
+
+ @Override
+ public void query(String term, int page, Response<Account> response) {
+ List<Account> members = new ArrayList<>();
+ term = term.toLowerCase();
+ for (OrganizationMembership membership: organizationModel.getObject().getOrganizationMembers()) {
+ Account user = membership.getUser();
+ if (user.getName().toLowerCase().contains(term)
+ || user.getFullName()!=null && user.getFullName().toLowerCase().contains(term)) {
+ members.add(user);
+ }
+ }
+ members.sort((user1, user2) -> user1.getName().compareTo(user2.getName()));
+
+ int from = page * Constants.DEFAULT_PAGE_SIZE;
+ int to = from + Constants.DEFAULT_PAGE_SIZE;
+
+ if (to > members.size()) {
+ to = members.size();
+ }
+ if (from > to) {
+ from = to;
+ }
+ response.addAll(members.subList(from, to));
+ response.setHasMore(to<members.size());
+ }
+
+ @Override
+ public void detach() {
+ organizationModel.detach();
+ super.detach();
+ }
+
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.css
index 9fedb14a38..032a641d55 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.css
@@ -1,168 +1,167 @@
-html, body {
- background: #F7F6F2;
-}
-
-.center-box {
- padding: 50px;
- width: 600px;
- margin: 0 auto;
- background: white;
- border: 8px solid #DDD;
- margin-top: 100px;
- margin-bottom: 20px;
- color: #333;
-}
-
-/* COMMON STYLES */
-a {
- cursor: pointer;
-}
-a.fa {
- text-decoration: none;
- color: #666;
-}
-table {
- width: 100%;
-}
-table>tbody>tr>td {
- vertical-align: top;
-}
-table.table>thead>tr>th>a {
- color: black;
- text-decoration: underline;
-}
-
-textarea {
- resize: vertical;
-}
-form>.actions {
- margin-top: 20px;
-}
-form>.actions>.btn {
- margin-right: 20px;
-}
-.actions>a {
- margin-right: 8px;
-}
-
-.nav-tabs>li>a {
- color: #777;
-}
-ul.pagination {
- margin: 0;
-}
-div.center {
- text-align: center;
-}
-
-.middot:before {
- content: ".";
- font-size: 20px;
- line-height: 12px;
- vertical-align: top;
- color: #666;
-}
-
-.input-group>.form-control+.btn.input-group-addon {
- border-radius: 0 4px 4px 0;
- border-left: none;
-}
-
-li.selectable a, a.selectable {
- border: 1px solid white;
- text-decoration: none;
- display: block;
- padding: 2px 4px;
- color: #333;
-}
-li.selectable:hover a, a.selectable:hover {
- background-color: #E0F0FC;
- border-color: #BBDFF9;
-}
-li.selectable.active a, a.selectable.active {
- background-color: #CBE8FB;
- border-color: #8BC8F9;
-}
-
-.activity-summary, .activity-summary a {
- color: #999;
-}
-.activity-summary .operations {
- margin-left: 8px;
-}
-.activity-summary .operations>a, .activity-summary .operations>span {
- margin-right: 6px;
- color: #DDD;
-}
-.activity-summary .operations a, .activity-summary .operations span {
- color: #DDD;
-}
-.activity-summary:hover .operations a, .activity-summary:hover .operations span {
- color: #999;
-}
-.activity-summary .user a, .activity-summary em {
- color: #666;
- font-weight: bold;
- font-style: normal;
-}
-
-.ellipsis-expander {
- display: inline-block;
- background: #DDD;
- padding: 0px 6px;
- border-radius: 2px;
- color: #777;
- vertical-align: middle;
- line-height: 16px;
-}
-.ellipsis-expander .fa {
- color: #666;
-}
-.ellipsis-expander:hover {
- background: #888;
-}
-.ellipsis-expander:hover .fa {
- color: white;
-}
-
-input.search {
- width: 200px;
-}
-
-.list>.head {
- margin-bottom: 20px;
-}
-.list>.head>.pull-left {
- margin-right: 20px;
-}
-
-.floating>.content>.selection {
- padding: 16px;
-}
-.floating>.content>.selection>a {
- padding: 4px;
- display: block;
- color: #666;
- text-decoration: none;
- max-width: 360px;
-}
-.floating>.content>.selection>a.active:BEFORE {
- font-family: "FontAwesome";
- content: "\f00c";
- position: absolute;
- left: 4px;
-}
-.floating>.content>.selection>a>.title {
- font-weight: bold;
- margin-bottom: 2px;
-}
-.floating>.content>.selection>a:hover {
- background: #F0F0F0;
-}
-
-.nav-tabs {
- margin-bottom: 20px;
-}
-.nav-tabs>li>a>.badge {
- margin-left: 8px;
-}
+html, body {
+ background: #F7F6F2;
+}
+
+.center-box {
+ padding: 50px;
+ width: 600px;
+ margin: 0 auto;
+ background: white;
+ border: 8px solid #DDD;
+ margin-top: 100px;
+ margin-bottom: 20px;
+ color: #333;
+}
+
+/* COMMON STYLES */
+a {
+ cursor: pointer;
+}
+a.fa {
+ text-decoration: none;
+ color: #666;
+}
+table {
+ width: 100%;
+}
+table>tbody>tr>td {
+ vertical-align: top;
+}
+table.table>thead>tr>th>a {
+ color: black;
+ text-decoration: underline;
+}
+
+textarea {
+ resize: vertical;
+}
+form>.actions {
+ margin-top: 20px;
+}
+form>.actions>.btn {
+ margin-right: 12px;
+}
+.actions>a {
+ margin-right: 8px;
+}
+.nav-tabs>li>a {
+ color: #777;
+}
+ul.pagination {
+ margin: 0;
+}
+div.center {
+ text-align: center;
+}
+
+.middot:before {
+ content: ".";
+ font-size: 20px;
+ line-height: 12px;
+ vertical-align: top;
+ color: #666;
+}
+
+.input-group>.form-control+.btn.input-group-addon {
+ border-radius: 0 4px 4px 0;
+ border-left: none;
+}
+
+li.selectable a, a.selectable {
+ border: 1px solid white;
+ text-decoration: none;
+ display: block;
+ padding: 2px 4px;
+ color: #333;
+}
+li.selectable:hover a, a.selectable:hover {
+ background-color: #E0F0FC;
+ border-color: #BBDFF9;
+}
+li.selectable.active a, a.selectable.active {
+ background-color: #CBE8FB;
+ border-color: #8BC8F9;
+}
+
+.activity-summary, .activity-summary a {
+ color: #999;
+}
+.activity-summary .operations {
+ margin-left: 8px;
+}
+.activity-summary .operations>a, .activity-summary .operations>span {
+ margin-right: 6px;
+ color: #DDD;
+}
+.activity-summary .operations a, .activity-summary .operations span {
+ color: #DDD;
+}
+.activity-summary:hover .operations a, .activity-summary:hover .operations span {
+ color: #999;
+}
+.activity-summary .user a, .activity-summary em {
+ color: #666;
+ font-weight: bold;
+ font-style: normal;
+}
+
+.ellipsis-expander {
+ display: inline-block;
+ background: #DDD;
+ padding: 0px 6px;
+ border-radius: 2px;
+ color: #777;
+ vertical-align: middle;
+ line-height: 16px;
+}
+.ellipsis-expander .fa {
+ color: #666;
+}
+.ellipsis-expander:hover {
+ background: #888;
+}
+.ellipsis-expander:hover .fa {
+ color: white;
+}
+
+input.search {
+ width: 200px;
+}
+
+.list>.head {
+ margin-bottom: 20px;
+}
+.list>.head>.pull-left {
+ margin-right: 20px;
+}
+
+.floating>.content>.selection {
+ padding: 16px;
+}
+.floating>.content>.selection>a {
+ padding: 4px;
+ display: block;
+ color: #666;
+ text-decoration: none;
+ max-width: 360px;
+}
+.floating>.content>.selection>a.active:BEFORE {
+ font-family: "FontAwesome";
+ content: "\f00c";
+ position: absolute;
+ left: 4px;
+}
+.floating>.content>.selection>a>.title {
+ font-weight: bold;
+ margin-bottom: 2px;
+}
+.floating>.content>.selection>a:hover {
+ background: #F0F0F0;
+}
+
+.nav-tabs {
+ margin-bottom: 20px;
+}
+.nav-tabs>li>a>.badge {
+ margin-left: 8px;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.java
index 7bca191387..c09f4562f0 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.java
@@ -81,6 +81,7 @@ import com.pmease.gitplex.web.page.depot.DepotPage;
import com.pmease.gitplex.web.page.depot.NoCommitsPage;
import com.pmease.gitplex.web.page.depot.pullrequest.PullRequestPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.changes.RequestChangesPage;
+import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.codecomments.CodeCommentsPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.integrationpreview.IntegrationPreviewPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview.RequestOverviewPage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.updates.RequestUpdatesPage;
@@ -259,6 +260,7 @@ public abstract class RequestDetailPage extends PullRequestPage {
tabs.add(new RequestTab("Overview", RequestOverviewPage.class));
tabs.add(new RequestTab("Updates", RequestUpdatesPage.class));
tabs.add(new RequestTab("File Changes", RequestChangesPage.class));
+ tabs.add(new RequestTab("Code Comments", CodeCommentsPage.class));
tabs.add(new RequestTab("Integration Preview", IntegrationPreviewPage.class));
add(new Tabbable("requestTabs", tabs).setOutputMarkupId(true));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.html
new file mode 100644
index 0000000000..25b5439916
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.html
@@ -0,0 +1,3 @@
+<wicket:extend>
+ <div wicket:id="codeComments"></div>
+</wicket:extend>
\ No newline at end of file
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
new file mode 100644
index 0000000000..91e4f31625
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/codecomments/CodeCommentsPage.java
@@ -0,0 +1,73 @@
+package com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.codecomments;
+
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+import com.pmease.gitplex.core.entity.CodeComment;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.web.component.comment.CodeCommentAware;
+import com.pmease.gitplex.web.component.comment.CodeCommentFilterOption;
+import com.pmease.gitplex.web.component.comment.CodeCommentListPanel;
+import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.RequestDetailPage;
+
+@SuppressWarnings("serial")
+public class CodeCommentsPage extends RequestDetailPage implements CodeCommentAware {
+
+ private final CodeCommentFilterOption filterOption;
+
+ private final List<String> commentedFiles = new ArrayList<>();
+
+ public CodeCommentsPage(PageParameters params) {
+ super(params);
+
+ filterOption = new CodeCommentFilterOption(params);
+
+ for (CodeComment comment: getPullRequest().getCodeComments()) {
+ if (comment.getPath() != null)
+ commentedFiles.add(comment.getPath());
+ }
+ commentedFiles.sort((file1, file2)->Paths.get(file1).compareTo(Paths.get(file2)));
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(new CodeCommentListPanel("codeComments", new IModel<CodeCommentFilterOption>() {
+
+ @Override
+ public void detach() {
+ }
+
+ @Override
+ public CodeCommentFilterOption getObject() {
+ return filterOption;
+ }
+
+ @Override
+ public void setObject(CodeCommentFilterOption object) {
+ PageParameters params = paramsOf(getPullRequest());
+ object.fillPageParams(params);
+ setResponsePage(CodeCommentsPage.class, params);
+ }
+
+ }) {
+
+ @Override
+ protected PullRequest getPullRequest() {
+ return CodeCommentsPage.this.getPullRequest();
+ }
+
+ });
+ }
+
+ @Override
+ public List<String> getCommentedFiles() {
+ return commentedFiles;
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.java
index 0150adc1d4..060d4366a9 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.java
@@ -335,7 +335,6 @@ public class RequestListPage extends PullRequestPage {
};
DataTable<PullRequest, Void> dataTable = new DataTable<>("pullRequests", columns,
dataProvider, Constants.DEFAULT_PAGE_SIZE);
- dataTable.addTopToolbar(new NavigationToolbar(dataTable));
dataTable.addBottomToolbar(new NoRecordsToolbar(dataTable));
dataTable.addBottomToolbar(new NavigationToolbar(dataTable));
add(dataTable);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/SearchOption.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/SearchOption.java
index be745bbfce..c7faaa1214 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/SearchOption.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/SearchOption.java
@@ -1,185 +1,185 @@
-package com.pmease.gitplex.web.page.depot.pullrequest.requestlist;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.validation.constraints.NotNull;
-
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.hibernate.criterion.Restrictions;
-
-import com.pmease.commons.hibernate.dao.EntityCriteria;
-import com.pmease.commons.wicket.editable.annotation.Editable;
-import com.pmease.gitplex.core.annotation.BranchChoice;
-import com.pmease.gitplex.core.annotation.UserChoice;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-
-@SuppressWarnings("serial")
-@Editable
-public class SearchOption implements Serializable {
-
- private static final String PARAM_STATUS = "status";
-
- private static final String PARAM_ASSIGNEE = "assignee";
-
- private static final String PARAM_SUBMITTER = "submitter";
-
- private static final String PARAM_TARGET = "target";
-
- private static final String PARAM_TITLE = "title";
-
- private static final String PARAM_BEGIN_DATE = "begin";
-
- private static final String PARAM_END_DATE = "end";
-
- public enum Status {OPEN, CLOSED, ALL};
-
- private Status status = Status.OPEN;
-
- private String assigneeName;
-
- private String submitterName;
-
- private String targetBranch;
-
- private String title;
-
- private Date beginDate;
-
- private Date endDate;
-
- @Editable(order=100)
- @NotNull
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-
- @Editable(order=200, name="Assigned To")
- @UserChoice
- public String getAssigneeName() {
- return assigneeName;
- }
-
- public void setAssigneeName(String assigneeName) {
- this.assigneeName = assigneeName;
- }
-
- @Editable(order=300, name="Submitted By")
- @UserChoice
- public String getSubmitterName() {
- return submitterName;
- }
-
- public void setSubmitterName(String submitterName) {
- this.submitterName = submitterName;
- }
-
- @Editable(order=400)
- @BranchChoice
- public String getTargetBranch() {
- return targetBranch;
- }
-
- public void setTargetBranch(String targetBranch) {
- this.targetBranch = targetBranch;
- }
-
- @Editable(order=500, name="Title Containing")
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- @Editable(order=700, name="Submitted After", description="Date should be specified with format <i>yyyy-MM-dd</i>.")
- public Date getBeginDate() {
- return beginDate;
- }
-
- public void setBeginDate(Date beginDate) {
- this.beginDate = beginDate;
- }
-
- @Editable(order=800, name="Submitted Before", description="Date should be specified with format <i>yyyy-MM-dd</i>.")
- public Date getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Date endDate) {
- this.endDate = endDate;
- }
-
- public SearchOption() {
- }
-
- public SearchOption(PageParameters params) {
- String value = params.get(PARAM_STATUS).toString();
- if (value != null)
- status = Status.valueOf(value);
-
- assigneeName = params.get(PARAM_ASSIGNEE).toString();
-
- submitterName = params.get(PARAM_SUBMITTER).toString();
-
- targetBranch = params.get(PARAM_TARGET).toString();
- title = params.get(PARAM_TITLE).toString();
-
- value = params.get(PARAM_BEGIN_DATE).toString();
- if (value != null)
- beginDate = new Date(Long.valueOf(value));
-
- value = params.get(PARAM_END_DATE).toString();
- if (value != null)
- endDate = new Date(Long.valueOf(value));
- }
-
- public EntityCriteria<PullRequest> getCriteria(Depot depot) {
- EntityCriteria<PullRequest> criteria = EntityCriteria.of(PullRequest.class);
- criteria.add(Restrictions.eq("targetDepot", depot));
-
- if (status == Status.OPEN)
- criteria.add(PullRequest.CriterionHelper.ofOpen());
- else if (status == Status.CLOSED)
- criteria.add(PullRequest.CriterionHelper.ofClosed());
-
- if (submitterName != null) {
- criteria.createCriteria("submitter").add(Restrictions.eq("name", submitterName));
- }
- if (assigneeName != null) {
- criteria.createCriteria("assignee").add(Restrictions.eq("name", assigneeName));
- }
- if (targetBranch != null)
- criteria.add(Restrictions.eq("targetBranch", targetBranch));
- if (title != null)
- criteria.add(Restrictions.ilike("title", "%" + title + "%"));
- if (beginDate != null)
- criteria.add(Restrictions.ge("createDate", beginDate));
- if (endDate != null)
- criteria.add(Restrictions.le("createDate", endDate));
- return criteria;
- }
-
- public void fillPageParams(PageParameters params) {
- params.set(PARAM_STATUS, status.name());
- if (assigneeName != null)
- params.set(PARAM_ASSIGNEE, assigneeName);
- if (submitterName != null)
- params.set(PARAM_SUBMITTER, submitterName);
- if (targetBranch != null)
- params.set(PARAM_TARGET, targetBranch);
- if (title != null)
- params.set(PARAM_TITLE, title);
- if (beginDate != null)
- params.set(PARAM_BEGIN_DATE, beginDate.getTime());
- if (endDate != null)
- params.set(PARAM_END_DATE, endDate.getTime());
- }
-
-}
+package com.pmease.gitplex.web.page.depot.pullrequest.requestlist;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.annotation.BranchChoice;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+
+@SuppressWarnings("serial")
+@Editable
+public class SearchOption implements Serializable {
+
+ private static final String PARAM_STATUS = "status";
+
+ private static final String PARAM_ASSIGNEE = "assignee";
+
+ private static final String PARAM_SUBMITTER = "submitter";
+
+ private static final String PARAM_TARGET = "target";
+
+ private static final String PARAM_TITLE = "title";
+
+ private static final String PARAM_BEGIN_DATE = "begin";
+
+ private static final String PARAM_END_DATE = "end";
+
+ public enum Status {OPEN, CLOSED, ALL};
+
+ private Status status = Status.OPEN;
+
+ private String assigneeName;
+
+ private String submitterName;
+
+ private String targetBranch;
+
+ private String title;
+
+ private Date beginDate;
+
+ private Date endDate;
+
+ @Editable(order=100)
+ @NotNull
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ @Editable(order=200, name="Assigned To")
+ @AccountChoice
+ public String getAssigneeName() {
+ return assigneeName;
+ }
+
+ public void setAssigneeName(String assigneeName) {
+ this.assigneeName = assigneeName;
+ }
+
+ @Editable(order=300, name="Submitted By")
+ @AccountChoice
+ public String getSubmitterName() {
+ return submitterName;
+ }
+
+ public void setSubmitterName(String submitterName) {
+ this.submitterName = submitterName;
+ }
+
+ @Editable(order=400)
+ @BranchChoice
+ public String getTargetBranch() {
+ return targetBranch;
+ }
+
+ public void setTargetBranch(String targetBranch) {
+ this.targetBranch = targetBranch;
+ }
+
+ @Editable(order=500, name="Title Containing")
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Editable(order=700, name="Submitted After", description="Date should be specified with format <i>yyyy-MM-dd</i>.")
+ public Date getBeginDate() {
+ return beginDate;
+ }
+
+ public void setBeginDate(Date beginDate) {
+ this.beginDate = beginDate;
+ }
+
+ @Editable(order=800, name="Submitted Before", description="Date should be specified with format <i>yyyy-MM-dd</i>.")
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ public SearchOption() {
+ }
+
+ public SearchOption(PageParameters params) {
+ String value = params.get(PARAM_STATUS).toString();
+ if (value != null)
+ status = Status.valueOf(value);
+
+ assigneeName = params.get(PARAM_ASSIGNEE).toString();
+
+ submitterName = params.get(PARAM_SUBMITTER).toString();
+
+ targetBranch = params.get(PARAM_TARGET).toString();
+ title = params.get(PARAM_TITLE).toString();
+
+ value = params.get(PARAM_BEGIN_DATE).toString();
+ if (value != null)
+ beginDate = new Date(Long.valueOf(value));
+
+ value = params.get(PARAM_END_DATE).toString();
+ if (value != null)
+ endDate = new Date(Long.valueOf(value));
+ }
+
+ public EntityCriteria<PullRequest> getCriteria(Depot depot) {
+ EntityCriteria<PullRequest> criteria = EntityCriteria.of(PullRequest.class);
+ criteria.add(Restrictions.eq("targetDepot", depot));
+
+ if (status == Status.OPEN)
+ criteria.add(PullRequest.CriterionHelper.ofOpen());
+ else if (status == Status.CLOSED)
+ criteria.add(PullRequest.CriterionHelper.ofClosed());
+
+ if (submitterName != null) {
+ criteria.createCriteria("submitter").add(Restrictions.eq("name", submitterName));
+ }
+ if (assigneeName != null) {
+ criteria.createCriteria("assignee").add(Restrictions.eq("name", assigneeName));
+ }
+ if (targetBranch != null)
+ criteria.add(Restrictions.eq("targetBranch", targetBranch));
+ if (title != null)
+ criteria.add(Restrictions.ilike("title", "%" + title + "%"));
+ if (beginDate != null)
+ criteria.add(Restrictions.ge("createDate", beginDate));
+ if (endDate != null)
+ criteria.add(Restrictions.le("createDate", endDate));
+ return criteria;
+ }
+
+ public void fillPageParams(PageParameters params) {
+ params.set(PARAM_STATUS, status.name());
+ if (assigneeName != null)
+ params.set(PARAM_ASSIGNEE, assigneeName);
+ if (submitterName != null)
+ params.set(PARAM_SUBMITTER, submitterName);
+ if (targetBranch != null)
+ params.set(PARAM_TARGET, targetBranch);
+ if (title != null)
+ params.set(PARAM_TITLE, title);
+ if (beginDate != null)
+ params.set(PARAM_BEGIN_DATE, beginDate.getTime());
+ if (endDate != null)
+ params.set(PARAM_END_DATE, endDate.getTime());
+ }
+
+}