The Unified and Autonomous Development Platform
go ahead
robin shine23736718d467
diff --git a/commons.git/src/main/java/com/pmease/commons/git/Git.java b/commons.git/src/main/java/com/pmease/commons/git/Git.javaindex 6aadd73093..cf3816aa20 100644--- a/commons.git/src/main/java/com/pmease/commons/git/Git.java+++ b/commons.git/src/main/java/com/pmease/commons/git/Git.java@@ -9,8 +9,6 @@ import java.util.Map;import javax.annotation.Nullable;-import org.eclipse.jgit.lib.FileMode;-import com.google.common.base.Preconditions;import com.pmease.commons.git.command.AddCommand;import com.pmease.commons.git.command.AddNoteCommand;@@ -36,18 +34,15 @@ import com.pmease.commons.git.command.ListFileChangesCommand;import com.pmease.commons.git.command.ListHeadCommitCommand;import com.pmease.commons.git.command.ListSubModulesCommand;import com.pmease.commons.git.command.ListTagsCommand;-import com.pmease.commons.git.command.ListTreeCommand;import com.pmease.commons.git.command.LogCommand;import com.pmease.commons.git.command.MergeCommand;import com.pmease.commons.git.command.MergeCommand.FastForwardMode;import com.pmease.commons.git.command.MoveCommand;import com.pmease.commons.git.command.ParseRevisionCommand;-import com.pmease.commons.git.command.PullCommand;import com.pmease.commons.git.command.PushCommand;import com.pmease.commons.git.command.RemoveCommand;import com.pmease.commons.git.command.ResetCommand;import com.pmease.commons.git.command.ShowCommand;-import com.pmease.commons.git.command.ShowRefCommand;import com.pmease.commons.git.command.ShowSymbolicRefCommand;import com.pmease.commons.git.command.UpdateRefCommand;import com.pmease.commons.git.command.UpdateSymbolicRefCommand;@@ -123,21 +118,6 @@ public class Git implements Serializable {return commits.get(0);}- /**- * List tree of specified revision under specified path.- *- * @param revision- * revision to list the tree off- * @param path- * path to list tree for. Note that if path is not empty and does not end- * with slash, this method will list the path itself, instead of listing- * child entries under this path- * @return- */- public List<TreeNode> listTree(String revision, @Nullable String path) {- return new ListTreeCommand(repoDir).revision(revision).path(path).call();- }-public Git init(boolean bare) {new InitCommand(repoDir).bare(bare).call();return this;@@ -273,16 +253,6 @@ public class Git implements Serializable {return this;}- public Git pull(String from, String... refspec) {- new PullCommand(repoDir).from(from).refspec(refspec).call();- return this;- }-- public Git pull(Git from, String... refspec) {- new PullCommand(repoDir).from(from.repoDir.getAbsolutePath()).refspec(refspec).call();- return this;- }-public Git push(String to, String... refspec) {new PushCommand(repoDir).to(to).refspec(refspec).call();return this;@@ -293,10 +263,6 @@ public class Git implements Serializable {return this;}- public List<RefInfo> showRefs(String pattern) {- return new ShowRefCommand(repoDir).pattern(pattern).call();- }-/*** Parse commit hash of specified revision.*@@ -394,17 +360,6 @@ public class Git implements Serializable {return new ShowCommand(repoDir).revision(revision).path(path).call();}- public byte[] readBlob(BlobIdent blob) {- if (blob.mode == FileMode.TYPE_GITLINK) {- String subModuleUrl = listSubModules(blob.revision).get(blob.path);- Preconditions.checkNotNull(subModuleUrl);- List<TreeNode> result = listTree(blob.revision, blob.path);- return (subModuleUrl + ":" + result.iterator().next().getHash()).getBytes();- } else {- return show(blob.revision, blob.path);- }- }-public List<Commit> log(@Nullable String fromRev, @Nullable String toRev,@Nullable String path, int maxCount, int skip) {return new LogCommand(repoDir).fromRev(fromRev).toRev(toRev)diff --git a/commons.git/src/main/java/com/pmease/commons/git/RefInfo.java b/commons.git/src/main/java/com/pmease/commons/git/RefInfo.javadeleted file mode 100644index fda0760a0f..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/RefInfo.java+++ /dev/null@@ -1,22 +0,0 @@-package com.pmease.commons.git;--public class RefInfo {-- private final String name;-- private final String commitHash;-- public RefInfo(final String name, final String commitHash) {- this.name = name;- this.commitHash = commitHash;- }-- public String getName() {- return name;- }-- public String getCommitHash() {- return commitHash;- }--}diff --git a/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java b/commons.git/src/main/java/com/pmease/commons/git/TreeNode.javadeleted file mode 100644index 21bb35634f..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java+++ /dev/null@@ -1,89 +0,0 @@-package com.pmease.commons.git;--import java.io.Serializable;--import org.apache.commons.lang3.StringUtils;-import org.eclipse.jgit.lib.FileMode;--@SuppressWarnings("serial")-public class TreeNode implements Comparable<TreeNode>, Serializable {-- private final int mode;-- private final String path;-- private transient String name;-- private final String hash;-- private final int size;-- /**- * Construct a tree node.- *- * @param modeBits- * mode bits of the node object. Pass <tt>0</tt> if unknown- * @param path- * path of the node object- * @param hash- * hash of the node object- * @param size- * size of the node object- */- public TreeNode(int modeBits, String path, String hash, int size) {- this.path = path;- this.hash = hash;- this.mode = modeBits;- this.size = size;- }-- public String getPath() {- return path;- }-- public String getName() {- if (name == null) {- if (path.contains("/"))- name = StringUtils.substringAfterLast(path, "/");- else- name = path;- }- return name;- }-- public String getHash() {- return hash;- }-- public int getMode() {- return mode;- }-- public boolean isFolder() {- return mode == FileMode.TYPE_TREE;- }-- public int getSize() {- return size;- }-- @Override- public String toString() {- return getPath();- }-- @Override- public int compareTo(TreeNode node) {- if (getMode() == FileMode.TYPE_TREE) {- if (node.getMode() == FileMode.TYPE_TREE)- return getName().compareTo(node.getName());- else- return -1;- } else if (node.getMode() == FileMode.TYPE_TREE) {- return 1;- } else {- return getName().compareTo(node.getName());- }- }--}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.javadeleted file mode 100644index 46f49bbeaf..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java+++ /dev/null@@ -1,85 +0,0 @@-package com.pmease.commons.git.command;--import java.io.File;-import java.util.ArrayList;-import java.util.Collections;-import java.util.List;--import org.apache.commons.lang3.StringUtils;-import org.apache.commons.lang3.math.NumberUtils;-import org.eclipse.jgit.util.QuotedString;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.google.common.base.Preconditions;-import com.pmease.commons.git.TreeNode;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.commons.util.execution.LineConsumer;--public class ListTreeCommand extends GitCommand<List<TreeNode>> {-- private static final Logger logger = LoggerFactory.getLogger(ListTreeCommand.class);-- private String revision;-- private String path;-- public ListTreeCommand(final File repoDir) {- super(repoDir);- }-- public ListTreeCommand revision(String revision) {- this.revision = revision;- return this;- }-- public ListTreeCommand path(String path) {- this.path = path;- return this;- }-- @Override- public List<TreeNode> call() {- Preconditions.checkNotNull(revision, "revision has to be specified for browse.");-- Commandline cmd = cmd().addArgs("ls-tree", "-l", "--full-name");- cmd.addArgs(revision);-- if (path != null)- cmd.addArgs(path);-- final List<TreeNode> treeNodes = new ArrayList<TreeNode>();-- cmd.execute(new LineConsumer() {-- @Override- public void consume(String line) {- String mode = StringUtils.substringBefore(line, " ");- line = StringUtils.substringAfter(line, " ");- line = StringUtils.substringAfter(line, " ");- String hash = StringUtils.substringBefore(line, " ");- line = StringUtils.substringAfter(line, " ");- int size = 0;- String sizeStr = StringUtils.substringBefore(line.trim(), "\t");- if (NumberUtils.isNumber(sizeStr))- size = Integer.parseInt(sizeStr);- String path = QuotedString.GIT_PATH.dequote(StringUtils.substringAfter(line.trim(), "\t"));-- treeNodes.add(new TreeNode(Integer.parseInt(mode, 8), path, hash, size));- }-- }, new LineConsumer() {-- @Override- public void consume(String line) {- logger.error(line);- }-- }).checkReturnCode();-- Collections.sort(treeNodes);-- return treeNodes;- }--}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/PullCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/PullCommand.javadeleted file mode 100644index 4b0f9dbebc..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/command/PullCommand.java+++ /dev/null@@ -1,68 +0,0 @@-package com.pmease.commons.git.command;--import java.io.File;--import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.google.common.base.Preconditions;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.commons.util.execution.LineConsumer;--public class PullCommand extends GitCommand<Void> {-- private static final Logger logger = LoggerFactory.getLogger(PullCommand.class);-- private String from;-- private String refspec[] = new String[0];-- public PullCommand(final File repoDir) {- super(repoDir);- }-- public PullCommand from(String from) {- this.from = from;- return this;- }-- public PullCommand refspec(String... refspec) {- this.refspec = refspec;- return this;- }-- @Override- public Void call() {- Preconditions.checkNotNull(from, "from param has to be specified.");- Preconditions.checkNotNull(refspec, "refspec param has to be specified.");-- Commandline cmd = cmd().addArgs("pull", from);-- for (String each: refspec)- cmd.addArgs(each);-- cmd.execute(new LineConsumer() {-- @Override- public void consume(String line) {- logger.debug(line);- }-- }, new LineConsumer() {-- @Override- public void consume(String line) {- if (line.startsWith("To "))- logger.info(line);- else if (line.startsWith(" * [new branch]"))- logger.info(line);- else- logger.error(line);- }-- }).checkReturnCode();-- return null;- }--}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ShowRefCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ShowRefCommand.javadeleted file mode 100644index e3d00fdfb8..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/command/ShowRefCommand.java+++ /dev/null@@ -1,68 +0,0 @@-package com.pmease.commons.git.command;--import java.io.File;-import java.util.ArrayList;-import java.util.List;--import org.apache.commons.lang3.StringUtils;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.google.common.base.Preconditions;-import com.pmease.commons.git.RefInfo;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.commons.util.execution.ExecuteResult;-import com.pmease.commons.util.execution.LineConsumer;--public class ShowRefCommand extends GitCommand<List<RefInfo>> {-- private static final Logger logger = LoggerFactory.getLogger(ShowRefCommand.class);-- private String pattern;-- public ShowRefCommand(File repoDir) {- super(repoDir);- }-- public ShowRefCommand pattern(String pattern) {- this.pattern = pattern;- return this;- }-- @Override- public List<RefInfo> call() {- Preconditions.checkNotNull(pattern, "pattern has to be specified.");-- Commandline cmd = cmd().addArgs("show-ref", pattern);-- final List<RefInfo> refs = new ArrayList<RefInfo>();- final boolean[] hasError = new boolean[]{false};- ExecuteResult result = cmd.execute(new LineConsumer() {-- @Override- public void consume(String line) {- String commitHash = StringUtils.substringBefore(line, " ");- String refName = StringUtils.substringAfter(line, " ");- refs.add(new RefInfo(refName, commitHash));- }-- }, new LineConsumer() {-- @Override- public void consume(String line) {- logger.error(line);- hasError[0] = true;- }-- });-- // When no refs are found, git returns error code 1, but we do not want- // to treat this as an error. Instead only when there are error messages- // being printed to stderr, we then check the return code.- if (hasError[0])- result.checkReturnCode();-- return refs;- }--}diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.javadeleted file mode 100644index 42455460a6..0000000000--- a/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java+++ /dev/null@@ -1,73 +0,0 @@-package com.pmease.commons.git.command;--import static org.junit.Assert.assertEquals;--import java.io.File;-import java.io.IOException;-import java.util.List;--import org.eclipse.jgit.lib.FileMode;-import org.junit.Test;--import com.pmease.commons.git.AbstractGitTest;-import com.pmease.commons.git.BlobIdent;-import com.pmease.commons.git.Git;-import com.pmease.commons.git.TreeNode;-import com.pmease.commons.util.FileUtils;-import com.pmease.commons.util.StringUtils;--public class ListTreeCommandTest extends AbstractGitTest {-- @Test- public void shouldListTreeAndReadFileCorrectly() throws IOException {- addFileAndCommit("a", "", "commit");- addFileAndCommit("b", "", "commit");- addFileAndCommit("c", "", "commit");- addFileAndCommit("d", "", "commit");- addFileAndCommit("a", "a", "commit");- createDir("dir");- addFileAndCommit("dir/file", "hello world", "commit");-- Git moduleGit = new Git(new File(tempDir, "module"));- moduleGit.init(false);- FileUtils.writeFile(new File(moduleGit.repoDir(), "readme"), "readme");- moduleGit.add("readme").commit("commit", false, false);-- git.addSubModule(moduleGit.repoDir().getAbsolutePath(), "module");- git.commit("commit", false, false);-- git.checkout("HEAD", "dev");- rm("dir/file");- commit("commit");-- Git bareGit = new Git(new File(tempDir, "bare"));- bareGit.clone(git, true, false, false, null);-- List<TreeNode> treeNodes = bareGit.listTree("master", null);-- assertEquals(7, treeNodes.size());- assertEquals("dir", treeNodes.get(0).getPath());- assertEquals("dir", treeNodes.get(0).getName());- assertEquals(FileMode.TYPE_TREE, treeNodes.get(0).getMode());-- TreeNode node = treeNodes.get(6);- BlobIdent blobInfo = new BlobIdent("master", node.getPath(), node.getMode());- String submoduleInfo = new String(bareGit.readBlob(blobInfo));- String submodulePath = new File(StringUtils.substringBeforeLast(submoduleInfo, ":")).getCanonicalPath();- String submoduleCommit = StringUtils.substringAfterLast(submoduleInfo, ":");- assertEquals(moduleGit.repoDir().getAbsolutePath(), submodulePath);- assertEquals(moduleGit.parseRevision("master", true), submoduleCommit);-- TreeNode dirNode = treeNodes.get(0);- treeNodes = bareGit.listTree("master", dirNode.getPath() + "/");-- assertEquals(1, treeNodes.size());- assertEquals("dir/file", treeNodes.get(0).getPath());- assertEquals("file", treeNodes.get(0).getName());-- TreeNode fileNode = treeNodes.get(0);- blobInfo = new BlobIdent("master", fileNode.getPath(), fileNode.getMode());- assertEquals("hello world", new String(bareGit.readBlob(blobInfo)));- }--}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/ajaxlistener/IndicateLoadingListener.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/ajaxlistener/IndicateLoadingListener.javanew file mode 100644index 0000000000..c58f965855--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/ajaxlistener/IndicateLoadingListener.java@@ -0,0 +1,52 @@+package com.pmease.commons.wicket.ajaxlistener;++import org.apache.wicket.Component;+import org.apache.wicket.ajax.attributes.IAjaxCallListener;++/**+ * Show global ajax loading indicator right away instead of using a timer.+ * This is useful in cases when loading a large page to cause timeout+ * callback not being able to be executed due to browser being busy.+ *+ * @author robin+ *+ */+public class IndicateLoadingListener implements IAjaxCallListener {++ @Override+ public CharSequence getBeforeHandler(Component component) {+ return null;+ }++ @Override+ public CharSequence getPrecondition(Component component) {+ return null;+ }++ @Override+ public CharSequence getBeforeSendHandler(Component component) {+ return "$('#ajax-loading-indicator').show();";+ }++ @Override+ public CharSequence getAfterHandler(Component component) {+ return null;+ }++ @Override+ public CharSequence getSuccessHandler(Component component) {+ return null;+ }++ @Override+ public CharSequence getFailureHandler(Component component) {+ return null;+ }++ @Override+ public CharSequence getCompleteHandler(Component component) {+ return null;+ }+++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffmode/DiffModePanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffmode/DiffModePanel.javaindex f2d1a12109..df26959855 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffmode/DiffModePanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffmode/DiffModePanel.java@@ -14,6 +14,8 @@ import org.apache.wicket.request.cycle.RequestCycle;import org.apache.wicket.request.http.WebRequest;import org.apache.wicket.request.http.WebResponse;+import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;+@SuppressWarnings("serial")public abstract class DiffModePanel extends Panel {@@ -49,44 +51,7 @@ public abstract class DiffModePanel extends Panel {@Overrideprotected void updateAjaxAttributes(AjaxRequestAttributes attributes) {super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new IAjaxCallListener() {-- @Override- public CharSequence getSuccessHandler(Component component) {- return null;- }-- @Override- public CharSequence getPrecondition(Component component) {- return null;- }-- @Override- public CharSequence getFailureHandler(Component component) {- return null;- }-- @Override- public CharSequence getCompleteHandler(Component component) {- return null;- }-- @Override- public CharSequence getBeforeSendHandler(Component component) {- return "$('#ajax-loading-indicator').show();";- }-- @Override- public CharSequence getBeforeHandler(Component component) {- return null;- }-- @Override- public CharSequence getAfterHandler(Component component) {- return null;- }-- });+ attributes.getAjaxCallListeners().add(new IndicateLoadingListener());}@Overridediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/lineprocess/LineProcessOptionMenu.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/lineprocess/LineProcessOptionMenu.javaindex 3d10176419..bfcf264622 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/lineprocess/LineProcessOptionMenu.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/lineprocess/LineProcessOptionMenu.java@@ -3,11 +3,10 @@ package com.pmease.gitplex.web.component.diff.lineprocess;import java.util.ArrayList;import java.util.List;-import org.apache.wicket.Component;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;-import org.apache.wicket.ajax.attributes.IAjaxCallListener;+import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;import com.pmease.commons.wicket.behavior.menu.CheckItem;import com.pmease.commons.wicket.behavior.menu.MenuItem;import com.pmease.commons.wicket.behavior.menu.MenuPanel;@@ -47,44 +46,7 @@ public abstract class LineProcessOptionMenu extends MenuPanel {@Overrideprotected void updateAjaxAttributes(AjaxRequestAttributes attributes) {super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new IAjaxCallListener() {-- @Override- public CharSequence getSuccessHandler(Component component) {- return null;- }-- @Override- public CharSequence getPrecondition(Component component) {- return null;- }-- @Override- public CharSequence getFailureHandler(Component component) {- return null;- }-- @Override- public CharSequence getCompleteHandler(Component component) {- return null;- }-- @Override- public CharSequence getBeforeSendHandler(Component component) {- return "$('#ajax-loading-indicator').show();";- }-- @Override- public CharSequence getBeforeHandler(Component component) {- return null;- }-- @Override- public CharSequence getAfterHandler(Component component) {- return null;- }-- });+ attributes.getAjaxCallListeners().add(new IndicateLoadingListener());}@Overridediff --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.htmlindex bc7daecbef..6f457e1d6b 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@@ -1,15 +1,17 @@<wicket:panel><div class="revision-diff"><div class="head clearfix">- <div class="title pull-left">+ <div class="pull-left">+ <span wicket:id="path" class="btn btn-sm btn-default" title="Filter changes by path">+ <span wicket:id="label"></span>+ <i class="fa fa-caret-down"></i>+ </span>+ <a wicket:id="clear" title="Clear path filter"><i class="fa fa-close"></i></a>+ <div wicket:id="pathDropdown"></div>+ </div>+ <div class="title pull-right"><span class="fa fa-ext fa-file-diff"></span> Total<a onclick="$(this).closest('.revision-diff').find('.diff-stats').toggle();$(document.body).trigger('sticky_kit:recalc');return false;"><span wicket:id="totalChanged"></span> changed files</a>- <wicket:enclosure child="totalAdditions">- with <strong wicket:id="totalAdditions"></strong>- </wicket:enclosure>- <wicket:enclosure child="totalDeletions">- and <strong wicket:id="totalDeletions"></strong>- </wicket:enclosure></div></div><div wicket:id="tooManyChanges" class="alert alert-warning">diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.javaindex a319d6cfd6..aab5d4776c 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@@ -13,6 +13,10 @@ import java.util.concurrent.Future;import javax.annotation.Nullable;import org.apache.wicket.AttributeModifier;+import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;+import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.behavior.AttributeAppender;import org.apache.wicket.markup.head.CssHeaderItem;import org.apache.wicket.markup.head.IHeaderResponse;@@ -31,6 +35,7 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType;import org.eclipse.jgit.diff.DiffFormatter;import org.eclipse.jgit.internal.storage.file.FileRepository;import org.eclipse.jgit.lib.AnyObjectId;+import org.eclipse.jgit.lib.FileMode;import org.eclipse.jgit.treewalk.filter.PathFilter;import org.eclipse.jgit.util.io.NullOutputStream;@@ -39,11 +44,15 @@ import com.pmease.commons.git.BlobChange;import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.LineProcessor;import com.pmease.commons.lang.diff.DiffUtils;+import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;+import com.pmease.commons.wicket.behavior.dropdown.DropdownBehavior;+import com.pmease.commons.wicket.behavior.dropdown.DropdownPanel;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.comment.InlineCommentSupport;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;import com.pmease.gitplex.web.component.diff.diffstat.DiffStatBar;+import com.pmease.gitplex.web.component.pathselector.PathSelector;@SuppressWarnings("serial")public abstract class RevisionDiffPanel extends Panel {@@ -53,7 +62,7 @@ public abstract class RevisionDiffPanel extends Panel {private final IModel<Repository> repoModel;@Nullable- private final String path;+ private String path;private final String oldRev;@@ -170,54 +179,74 @@ public abstract class RevisionDiffPanel extends Panel {protected void onInitialize() {super.onInitialize();- add(new Label("totalChanged", new AbstractReadOnlyModel<Integer>() {+ DropdownPanel pathDropdown = new DropdownPanel("pathDropdown", true) {@Override- public Integer getObject() {- return getChangesCount();+ protected Component newContent(String id) {+ return new PathSelector(id, repoModel, newRev, FileMode.TYPE_TREE,+ FileMode.TYPE_FILE, FileMode.TYPE_GITLINK, FileMode.TYPE_SYMLINK) {++ @Override+ protected void onSelect(AjaxRequestTarget target, BlobIdent blobIdent) {+ path = blobIdent.path;+ hide(target);+ target.add(RevisionDiffPanel.this);+ }++ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ attributes.getAjaxCallListeners().add(new IndicateLoadingListener());+ }++ };}- }));-- add(new Label("totalAdditions", new LoadableDetachableModel<String>() {+ };+ add(pathDropdown);+ WebMarkupContainer pathContainer = new WebMarkupContainer("path");+ pathContainer.add(new DropdownBehavior(pathDropdown));+ pathContainer.add(new Label("label", new AbstractReadOnlyModel<String>() {@Override- protected String load() {- int totalAdditions = 0;- for (BlobChange change: getChanges())- totalAdditions += change.getAdditions();- return totalAdditions + " additions";+ public String getObject() {+ if (path != null)+ return path;+ else+ return "Filter by";}- }) {+ }));+ add(new AjaxLink<Void>("clear") {@Override- protected void onConfigure() {- super.onConfigure();- setVisible(getChanges().size() == getChangesCount());+ public void onClick(AjaxRequestTarget target) {+ path = null;+ target.add(RevisionDiffPanel.this);}- });-- add(new Label("totalDeletions", new LoadableDetachableModel<String>() {-@Override- protected String load() {- int totalDeletions = 0;- for (BlobChange change: getChanges())- totalDeletions += change.getDeletions();- return totalDeletions + " deletions";+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new IndicateLoadingListener());}-- }) {@Overrideprotected void onConfigure() {super.onConfigure();- setVisible(getChanges().size() == getChangesCount());+ setVisible(path != null);}});+ add(pathContainer);++ add(new Label("totalChanged", new AbstractReadOnlyModel<Integer>() {++ @Override+ public Integer getObject() {+ return getChangesCount();+ }++ }));add(new WebMarkupContainer("tooManyChanges") {@@ -298,6 +327,8 @@ public abstract class RevisionDiffPanel extends Panel {}});++ setOutputMarkupId(true);}private List<BlobChange> getChanges() {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.htmlindex 71b1f249db..17673d3e01 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.html@@ -1,8 +1,5 @@<wicket:panel>- <div class="path-selector">- <div class="title">Select Below</div>- <div wicket:id="tree"></div>- </div>+ <div wicket:id="tree" class="path-selector"></div><wicket:fragment wicket:id="treeNodeFrag"><i wicket:id="icon"></i> <a wicket:id="link"><span wicket:id="label"></span></a></wicket:fragment>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.javaindex c18c094799..3648206bff 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/PathSelector.java@@ -9,9 +9,11 @@ import java.util.Set;import org.apache.wicket.Component;import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.extensions.markup.html.repeater.tree.DefaultNestedTree;import org.apache.wicket.extensions.markup.html.repeater.tree.ITreeProvider;+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;@@ -117,6 +119,12 @@ public abstract class PathSelector extends Panel {}) {+ @Override+ protected void onInitialize() {+ super.onInitialize();+ add(new HumanTheme());+ }+@Overrideprotected Component newContentComponent(String id, final IModel<BlobIdent> model) {BlobIdent blobIdent = model.getObject();@@ -125,9 +133,15 @@ public abstract class PathSelector extends Panel {WebMarkupContainer link;- if (pathTypes.contains(blobIdent.mode)) {+ if (pathTypes.contains(blobIdent.mode & FileMode.TYPE_MASK)) {link = new AjaxLink<Void>("link") {+ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ PathSelector.this.updateAjaxAttributes(attributes);+ }+@Overridepublic void onClick(AjaxRequestTarget target) {onSelect(target, model.getObject());@@ -174,4 +188,8 @@ public abstract class PathSelector extends Panel {}protected abstract void onSelect(AjaxRequestTarget target, BlobIdent blobIdent);++ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ }+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/path-selector.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/path-selector.cssindex 8a4e7e5de2..725b1ec7c3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/path-selector.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathselector/path-selector.css@@ -1,9 +1,5 @@.path-selector {- max-height: 650px;+ max-height: 600px;overflow: auto;padding: 12px 24px 12px 12px;}-.path-selector .title {- font-weight: bold;- border-bottom: 1px solid #888;-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/path/PathSingleChoiceEditor.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/path/PathSingleChoiceEditor.javaindex fc32b4208b..6323dbae20 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/path/PathSingleChoiceEditor.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/editable/path/PathSingleChoiceEditor.java@@ -66,6 +66,7 @@ public class PathSingleChoiceEditor extends PropertyEditor<String> {String script = String.format("gitplex.selectDirectory('%s', '%s', '%s', %s);",input.getMarkupId(), getMarkupId(), path, false);target.appendJavaScript(script);+ hide(target);}};