commit | author | age
|
6e6f9f
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package com.gitblit.wicket.panels;
|
|
17 |
|
|
18 |
import java.util.Collections;
|
|
19 |
import java.util.List;
|
|
20 |
|
|
21 |
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
|
22 |
import org.apache.wicket.markup.repeater.Item;
|
|
23 |
import org.apache.wicket.markup.repeater.data.DataView;
|
|
24 |
import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
79dd0b
|
25 |
import org.eclipse.jgit.lib.Repository;
|
6e6f9f
|
26 |
|
JM |
27 |
import com.gitblit.Constants;
|
e627cf
|
28 |
import com.gitblit.Keys;
|
db91a3
|
29 |
import com.gitblit.models.Activity;
|
f8bb95
|
30 |
import com.gitblit.models.RepositoryCommit;
|
db91a3
|
31 |
import com.gitblit.utils.StringUtils;
|
6e6f9f
|
32 |
import com.gitblit.wicket.WicketUtils;
|
JM |
33 |
import com.gitblit.wicket.pages.CommitDiffPage;
|
|
34 |
import com.gitblit.wicket.pages.CommitPage;
|
4e1930
|
35 |
import com.gitblit.wicket.pages.GitSearchPage;
|
ed3a0e
|
36 |
import com.gitblit.wicket.pages.LogPage;
|
6e6f9f
|
37 |
import com.gitblit.wicket.pages.SummaryPage;
|
JM |
38 |
import com.gitblit.wicket.pages.TreePage;
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Renders activity in day-blocks in reverse-chronological order.
|
699e71
|
42 |
*
|
6e6f9f
|
43 |
* @author James Moger
|
699e71
|
44 |
*
|
6e6f9f
|
45 |
*/
|
JM |
46 |
public class ActivityPanel extends BasePanel {
|
|
47 |
|
|
48 |
private static final long serialVersionUID = 1L;
|
|
49 |
|
db91a3
|
50 |
public ActivityPanel(String wicketId, List<Activity> recentActivity) {
|
6e6f9f
|
51 |
super(wicketId);
|
JM |
52 |
|
|
53 |
Collections.sort(recentActivity);
|
699e71
|
54 |
|
99d0d4
|
55 |
final int shortHashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);
|
db91a3
|
56 |
DataView<Activity> activityView = new DataView<Activity>("activity",
|
JM |
57 |
new ListDataProvider<Activity>(recentActivity)) {
|
6e6f9f
|
58 |
private static final long serialVersionUID = 1L;
|
JM |
59 |
|
699e71
|
60 |
@Override
|
ed3a0e
|
61 |
public void populateItem(final Item<Activity> activityItem) {
|
JM |
62 |
final Activity entry = activityItem.getModelObject();
|
9adf62
|
63 |
activityItem.add(WicketUtils.createDatestampLabel("title", entry.startDate, getTimeZone(), getTimeUtils()));
|
6e6f9f
|
64 |
|
JM |
65 |
// display the commits in chronological order
|
ed3a0e
|
66 |
DataView<RepositoryCommit> commits = new DataView<RepositoryCommit>("commit",
|
9d921f
|
67 |
new ListDataProvider<RepositoryCommit>(entry.getCommits())) {
|
6e6f9f
|
68 |
private static final long serialVersionUID = 1L;
|
JM |
69 |
|
699e71
|
70 |
@Override
|
ed3a0e
|
71 |
public void populateItem(final Item<RepositoryCommit> commitItem) {
|
JM |
72 |
final RepositoryCommit commit = commitItem.getModelObject();
|
6e6f9f
|
73 |
|
74e73c
|
74 |
// commit time of day
|
ed3a0e
|
75 |
commitItem.add(WicketUtils.createTimeLabel("time", commit.getCommitterIdent()
|
9adf62
|
76 |
.getWhen(), getTimeZone(), getTimeUtils()));
|
6e6f9f
|
77 |
|
JM |
78 |
// avatar
|
b57b9e
|
79 |
commitItem.add(new AvatarImage("avatar", commit.getAuthorIdent(), 40));
|
6e6f9f
|
80 |
|
JM |
81 |
// merge icon
|
|
82 |
if (commit.getParentCount() > 1) {
|
ed3a0e
|
83 |
commitItem.add(WicketUtils.newImage("commitIcon",
|
6e6f9f
|
84 |
"commit_merge_16x16.png"));
|
JM |
85 |
} else {
|
2ec0d7
|
86 |
commitItem.add(WicketUtils.newBlankImage("commitIcon").setVisible(false));
|
6e6f9f
|
87 |
}
|
JM |
88 |
|
|
89 |
// author search link
|
|
90 |
String author = commit.getAuthorIdent().getName();
|
|
91 |
LinkPanel authorLink = new LinkPanel("author", "list", author,
|
4e1930
|
92 |
GitSearchPage.class, WicketUtils.newSearchParameter(commit.repository,
|
b26eda
|
93 |
null, author, Constants.SearchType.AUTHOR), true);
|
6e6f9f
|
94 |
setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);
|
ed3a0e
|
95 |
commitItem.add(authorLink);
|
6e6f9f
|
96 |
|
db91a3
|
97 |
// repository
|
6c6fbf
|
98 |
String repoName = StringUtils.stripDotGit(commit.repository);
|
db91a3
|
99 |
LinkPanel repositoryLink = new LinkPanel("repository", null,
|
6c6fbf
|
100 |
repoName, SummaryPage.class,
|
797322
|
101 |
WicketUtils.newRepositoryParameter(commit.repository), true);
|
4ce036
|
102 |
WicketUtils.setCssBackground(repositoryLink, repoName);
|
ed3a0e
|
103 |
commitItem.add(repositoryLink);
|
6e6f9f
|
104 |
|
JM |
105 |
// repository branch
|
79dd0b
|
106 |
LinkPanel branchLink = new LinkPanel("branch", "list", Repository.shortenRefName(commit.branch),
|
6e6f9f
|
107 |
LogPage.class, WicketUtils.newObjectParameter(commit.repository,
|
797322
|
108 |
commit.branch), true);
|
6e6f9f
|
109 |
WicketUtils.setCssStyle(branchLink, "color: #008000;");
|
ed3a0e
|
110 |
commitItem.add(branchLink);
|
6e6f9f
|
111 |
|
JM |
112 |
LinkPanel commitid = new LinkPanel("commitid", "list subject",
|
e627cf
|
113 |
commit.getName().substring(0, shortHashLen), CommitPage.class,
|
797322
|
114 |
WicketUtils.newObjectParameter(commit.repository, commit.getName()), true);
|
ed3a0e
|
115 |
commitItem.add(commitid);
|
6e6f9f
|
116 |
|
JM |
117 |
// message/commit link
|
|
118 |
String shortMessage = commit.getShortMessage();
|
a45caa
|
119 |
String trimmedMessage = shortMessage;
|
JM |
120 |
if (commit.getRefs() != null && commit.getRefs().size() > 0) {
|
|
121 |
trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS);
|
|
122 |
} else {
|
|
123 |
trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG);
|
|
124 |
}
|
db91a3
|
125 |
LinkPanel shortlog = new LinkPanel("message", "list subject",
|
JM |
126 |
trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(
|
797322
|
127 |
commit.repository, commit.getName()), true);
|
db91a3
|
128 |
if (!shortMessage.equals(trimmedMessage)) {
|
JM |
129 |
WicketUtils.setHtmlTooltip(shortlog, shortMessage);
|
|
130 |
}
|
ed3a0e
|
131 |
commitItem.add(shortlog);
|
6e6f9f
|
132 |
|
JM |
133 |
// refs
|
ed3a0e
|
134 |
commitItem.add(new RefsPanel("commitRefs", commit.repository, commit
|
6e6f9f
|
135 |
.getRefs()));
|
JM |
136 |
|
f8337b
|
137 |
// diff, tree links
|
ed3a0e
|
138 |
commitItem.add(new BookmarkablePageLink<Void>("diff", CommitDiffPage.class,
|
6e6f9f
|
139 |
WicketUtils.newObjectParameter(commit.repository, commit.getName()))
|
JM |
140 |
.setEnabled(commit.getParentCount() > 0));
|
ed3a0e
|
141 |
commitItem.add(new BookmarkablePageLink<Void>("tree", TreePage.class,
|
699e71
|
142 |
WicketUtils.newObjectParameter(commit.repository, commit.getName())));
|
6e6f9f
|
143 |
}
|
JM |
144 |
};
|
ed3a0e
|
145 |
activityItem.add(commits);
|
6e6f9f
|
146 |
}
|
JM |
147 |
};
|
|
148 |
add(activityView);
|
|
149 |
}
|
|
150 |
}
|