Skip to content

The Unified and Autonomous Development Platform

midwork

robin shine404216dfbff7
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.html
index de915041b0..e406e33e1f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.html
@@ -1,23 +1,27 @@
<wicket:extend>
<div id="repo-commits">
- <ul class="list list-unstyled">
- <li wicket:id="commits" class="commit clearfix">
- <div class="avatar pull-left">
- <span wicket:id="avatar"></span>
- </div>
- <div class="detail pull-left">
- <div wicket:id="message"></div>
- <div class="author">
- <span wicket:id="name"></span> authored <span wicket:id="age"></span>
+ <div class="head"></div>
+ <div class="body">
+ <svg class="lane"></svg>
+ <ul class="list list-unstyled">
+ <li wicket:id="commits" class="commit clearfix">
+ <div class="avatar pull-left">
+ <span wicket:id="avatar"></span>
</div>
- </div>
- <div class="info pull-right">
- <span wicket:id="hash"></span>
- <a wicket:id="codeLink" title="Browse code at this point" class="btn btn-xs btn-default"><span class="fa fa-code"></span></a>
- </div>
- </li>
- </ul>
- <div wicket:id="footer" class="footer">
+ <div class="detail pull-left">
+ <div wicket:id="message"></div>
+ <div class="author">
+ <span wicket:id="name"></span> authored <span wicket:id="age"></span>
+ </div>
+ </div>
+ <div class="info pull-right">
+ <span wicket:id="hash"></span>
+ <a wicket:id="codeLink" title="Browse code at this point" class="btn btn-xs btn-default"><span class="fa fa-code"></span></a>
+ </div>
+ </li>
+ </ul>
+ </div>
+ <div wicket:id="foot" class="foot">
<a wicket:id="more" class="btn btn-default">More commits</a>
<div wicket:id="tooMany" class="alert alert-warning">Too many commits to load</div>
</div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.java
index e337c50159..b9531b2415 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.java
@@ -66,7 +66,7 @@ public class RepoCommitsPage extends RepositoryPage {
private RepeatingView commitsView;
- private WebMarkupContainer footer;
+ private WebMarkupContainer foot;
private IModel<LastAndCurrentCommits> lastAndCurrentCommitsModel = new LoadableDetachableModel<LastAndCurrentCommits>() {
@@ -174,10 +174,10 @@ public class RepoCommitsPage extends RepositoryPage {
add(commitsView = newCommitsView());
- footer = new WebMarkupContainer("footer");
- footer.setOutputMarkupId(true);
+ foot = new WebMarkupContainer("foot");
+ foot.setOutputMarkupId(true);
- footer.add(new AjaxLink<Void>("more") {
+ foot.add(new AjaxLink<Void>("more") {
@Override
public void onClick(AjaxRequestTarget target) {
@@ -200,11 +200,11 @@ public class RepoCommitsPage extends RepositoryPage {
Component item = newCommitItem(commitsView.newChildId(), i);
commitsView.add(item);
target.add(item);
- builder.append(String.format("$('#repo-commits>ul').append(\"<li id='%s'></li>\");",
+ builder.append(String.format("$('#repo-commits>.body>.list').append(\"<li id='%s'></li>\");",
item.getMarkupId()));
}
target.prependJavaScript(builder);
- target.add(footer);
+ target.add(foot);
target.appendJavaScript(getCommitLaneScript());
pushState(target);
@@ -217,7 +217,7 @@ public class RepoCommitsPage extends RepositoryPage {
}
});
- footer.add(new WebMarkupContainer("tooMany") {
+ foot.add(new WebMarkupContainer("tooMany") {
@Override
protected void onConfigure() {
@@ -226,7 +226,7 @@ public class RepoCommitsPage extends RepositoryPage {
}
});
- add(footer);
+ add(foot);
}
private void pushState(AjaxRequestTarget target) {
@@ -299,7 +299,7 @@ public class RepoCommitsPage extends RepositoryPage {
replace(commitsView = newCommitsView());
target.add(commitsView);
- target.add(footer);
+ target.add(foot);
}
@Override
@@ -326,7 +326,7 @@ public class RepoCommitsPage extends RepositoryPage {
}
try {
String json = GitPlex.getInstance(ObjectMapper.class).writeValueAsString(commitIndexes);
- return String.format("gitplex.repocommits.drawCommitLane(%s);", json);
+ return String.format("gitplex.repocommits.renderCommitLane(%s);", json);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.css
index 6c36a19bda..10d017a3d6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.css
@@ -1,52 +1,56 @@
#repo-commits {
padding: 20px;
+ position: relative;
}
-#repo-commits li {
+#repo-commits>.body li {
padding: 4px 0;
}
-#repo-commits .avatar {
+#repo-commits>.body .avatar {
width: 40px;
}
-#repo-commits .info {
- text-align: right;
- white-space: nowrap;
-}
-#repo-commits .avatar img {
+#repo-commits>.body .avatar img {
width: 37px;
height: 37px;
}
-#repo-commits a {
+#repo-commits>.body .info {
+ text-align: right;
+ white-space: nowrap;
+}
+#repo-commits>.body a {
color: #666;
}
-#repo-commits a.summary {
+#repo-commits>.body a.summary {
font-weight: bold;
}
-#repo-commits .detail {
+#repo-commits>.body .detail {
padding-left: 8px;
padding-right: 8px;
}
-#repo-commits .detail .name {
+#repo-commits>.body .detail .name {
color: #666;
}
-#repo-commits .commit-hash {
+#repo-commits>.body .commit-hash {
font-family: monospace;
}
-#repo-commits li:hover {
+#repo-commits>.body li:hover {
background: #F7ECB9;
}
-#repo-commits .commit-message>.full {
+#repo-commits>.body .commit-message>.full {
margin-bottom: 4px;
}
-#repo-commits .commit-message .detail {
+#repo-commits>.body .commit-message .detail {
margin-bottom: 8px;
}
-#repo-commits>ul {
+#repo-commits>.body>.list {
margin-bottom: 0;
}
-#repo-commits>.footer {
+#repo-commits>.body>.lane {
+ position: absolute;
+}
+#repo-commits>.foot {
text-align: center;
}
-#repo-commits>.footer>.alert, #repo-commits>.footer>.btn {
+#repo-commits>.foot>.alert, #repo-commits>.footer>.btn {
margin-top: 8px;
margin-bottom: 0;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.js
index 765dfc44c0..dbc741ef4b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.js
@@ -1,21 +1,28 @@
-gitplex.repocommits = {
-
+gitplex.repocommits = {
/*
* commits is an array of ordered commit object, and the commit object is itself a
* list of parent indexes
*/
- drawCommitLane: function(commits) {
-
+ renderCommitLane: function(commits) {
var columnsLimit = 20;
- var columnWidth = 20;
+
var colors = ["#0000ff", "#00ff00", "#ff0000",
"#ffff00", "#ff00ff", "#00ffff",
"#000080", "#008000", "#800000",
"#808000", "#800080", "#008080"];
- var colorStack = [];
+ /*
+ * rows store the map of line to row. A line represents a child->parent relationship.
+ * For instance line(1,5) represents the line from commit at row 1 (the child ) to
+ * commit at row 5 (the parent). In case child row index equals parent row index,
+ * the line represents a commit.
+ *
+ */
+ var rows = [];
+ var parent2children = {};
var colorAssignments = {};
-
+
+ var colorStack = [];
function getSortedLines(row, reverse) {
var lines = [];
var keys = Object.keys(row);
@@ -41,21 +48,24 @@ gitplex.repocommits = {
return line[0] + "," + line[1];
}
- /*
- * rows store the map of line to row. A line represents a child->parent relationship.
- * For instance line(1,5) represents the line from commit at row 1 (the child ) to
- * commit at row 5 (the parent). In case child row index equals parent row index,
- * the line represents a commit.
- *
- */
- var rows = [];
-
- var parent2children = {};
+ function assignColor(lineKey) {
+ var color = colorAssignments[lineKey];
+ if (color == undefined) {
+ if (colorStack.length == 0) {
+ for (var i=colors.length-1; i>=0; i--)
+ colorStack.push(colors[i]);
+ }
+ color = colorStack.pop();
+ colorAssignments[lineKey] = color;
+ }
+ return color;
+ }
for (var i=0; i<commits.length; i++) {
- var commit = commits[i][1];
- for (var j=0; j<commit.length; j++) {
- var parent = commit[j];
+ commits[i] = commits[i][1];
+ var parents = commits[i];
+ for (var j=0; j<parents.length; j++) {
+ var parent = parents[j];
var children = parent2children[parent];
if (children == undefined) {
children = [];
@@ -71,7 +81,7 @@ gitplex.repocommits = {
if (rowIndex == 0) {
row["0,0"] = 0;
} else {
- var commit = commits[rowIndex-1][1];
+ var commit = commits[rowIndex-1];
// special line represents the commit at rowIndex itself
var commitLineKey = toKey([rowIndex, rowIndex]);
var lastRow = rows[rowIndex-1];
@@ -186,15 +196,82 @@ gitplex.repocommits = {
for (var i=insertColumn+1; i<linesOfLastRow.length; i++)
lastRow[linesOfLastRow[i]] = column++;
}
+ for (var lineKey in row) {
+ var line = fromKey(lineKey);
+ if (line.child == line.parent) {
+ var children = parent2children[line.parent];
+ if (children) {
+ for (var i=0; i<children.length; i++) {
+ var child = children[i];
+ var lineToMe = [child, line.parent];
+ colorStack.push(assignColor(toKey(lineToMe)));
+ }
+ }
+ } else {
+ if (line.parent < 0)
+ assignColor(toKey([line.child, line.parent*-1]));
+ else
+ assignColor(toKey(line));
+ }
+ }
}
rows.push(row);
var keysLen = Object.keys(row).length;
if (keysLen > maxColumns)
maxColumns = keysLen;
}
+ gitplex.repocommits.rows = rows;
+ gitplex.repocommits.commits = commits;
+ gitplex.repocommits.colorAssignments = colorAssignments;
+ gitplex.repocommits.maxColumns = maxColumns;
- $("#repo-commits>ul").css("margin-left", maxColumns*columnWidth);
+ gitplex.repocommits.drawCommitLane();
+ },
+ drawCommitLane: function() {
+ var columnWidth = 20;
+ var topOffset = 12;
+ var rightOffset = 8;
+ var commitSize = 3;
+ var commitColor = "#0000ff";
+
+ var rows = gitplex.repocommits.rows;
+ var commits = gitplex.repocommits.commits;
+ var colorAssignments = gitplex.repocommits.colorAssignments;
+ var maxColumns = gitplex.repocommits.maxColumns;
+ function fromKey(lineKey) {
+ return lineKey.split(',').map(function(item) {
+ return parseInt(item, 10);
+ });
+ }
+
+ function toKey(line) {
+ return line[0] + "," + line[1];
+ }
+
+ var $list = $("#repo-commits>.body>.list");
+ $list.css("margin-left", maxColumns*columnWidth+8);
+
+ var $lane = $("#repo-commits>.body>.lane");
+ $lane.empty();
+ $lane.height($list.outerHeight());
+ $lane.width(maxColumns*columnWidth);
+ var paper = Snap($lane[0]);
+
+ var bodyTop = $("#repo-commits>.body").offset().top - rightOffset;
+ var commitGroup = paper.g();
+ for (var i=0; i<rows.length; i++) {
+ var row = rows[i];
+ var column = row[toKey([i, i])];
+ var top = $("#commitindex-"+i).offset().top - bodyTop;
+ var left = column*columnWidth + columnWidth/2;
+ commitGroup.add(paper.circle(left, top, commitSize));
+
+ if (i < rows.length-1) {
+
+ }
+ }
+ commitGroup.attr({fill: commitColor, stroke: commitColor});
}
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html
index e415318076..f343054aa7 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html
@@ -1,3 +1,9 @@
<wicket:extend>
- <a wicket:id="test">test</a>
-</wicket:extend>
+ <svg id="snap"></svg>
+ <script type="text/javascript">
+ $(function() {
+ var snap = Snap("#snap");
+ snap.circle(20, 20, 10);
+ });
+ </script>
+</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java
index 34542a3e78..b54311b970 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java
@@ -1,21 +1,8 @@
package com.pmease.gitplex.web.page.test;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.markup.html.link.Link;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.pmease.commons.git.Commit;
-import com.pmease.commons.git.CommitLane;
-import com.pmease.commons.git.command.LogCommand;
-import com.pmease.commons.git.command.LogCommand.Order;
import com.pmease.commons.wicket.assets.snapsvg.SnapSvgResourceReference;
import com.pmease.gitplex.web.page.base.BasePage;
@@ -25,49 +12,6 @@ public class TestPage extends BasePage {
@Override
protected void onInitialize() {
super.onInitialize();
-
- add(new Link<Void>("test") {
-
- @Override
- public void onClick() {
- LogCommand log = new LogCommand(new File("w:\\temp\\linux\\.git")).order(Order.DATE).maxCount(10000);
- List<Commit> commits = log.call();
-
- System.out.println(commits.size());
- Map<String, Integer> mapOfHashToRow = new HashMap<>();
- for (int i=0; i<commits.size(); i++) {
- Commit commit = commits.get(i);
- mapOfHashToRow.put(commit.getHash(), i);
- }
- Map<Integer, List<Integer>> mapOfChildToParents = new HashMap<>();
- Map<Integer, List<Integer>> mapOfParentToChildren = new HashMap<>();
- for (int i=0; i<commits.size(); i++) {
- Commit commit = commits.get(i);
- List<Integer> parents = new ArrayList<>();
- mapOfChildToParents.put(i, parents);
- for (String parentHash: commit.getParentHashes()) {
- Integer parent = mapOfHashToRow.get(parentHash);
- if (parent != null) {
- parents.add(parent);
- List<Integer> children = mapOfParentToChildren.get(parent);
- if (children == null) {
- children = new ArrayList<>();
- mapOfParentToChildren.put(parent, children);
- }
- children.add(i);
- }
- }
- }
-
- try {
- System.out.println(new ObjectMapper().writeValueAsString(new CommitLane(commits, Integer.MAX_VALUE)).length());
- System.out.println(new ObjectMapper().writeValueAsString(mapOfChildToParents).length());
- System.out.println(new ObjectMapper().writeValueAsString(mapOfParentToChildren).length());
- } catch (JsonProcessingException e) {
- }
- }
-
- });
}
@Override