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.html.panel.Fragment;
|
|
23 |
import org.apache.wicket.markup.repeater.Item;
|
|
24 |
import org.apache.wicket.markup.repeater.data.DataView;
|
|
25 |
import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
|
26 |
|
|
27 |
import com.gitblit.Constants;
|
|
28 |
import com.gitblit.models.DailyActivity;
|
|
29 |
import com.gitblit.models.RepositoryCommit;
|
|
30 |
import com.gitblit.wicket.GitBlitWebSession;
|
|
31 |
import com.gitblit.wicket.GravatarImage;
|
|
32 |
import com.gitblit.wicket.WicketUtils;
|
|
33 |
import com.gitblit.wicket.pages.CommitDiffPage;
|
|
34 |
import com.gitblit.wicket.pages.CommitPage;
|
|
35 |
import com.gitblit.wicket.pages.LogPage;
|
|
36 |
import com.gitblit.wicket.pages.SearchPage;
|
|
37 |
import com.gitblit.wicket.pages.SummaryPage;
|
|
38 |
import com.gitblit.wicket.pages.TreePage;
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Renders activity in day-blocks in reverse-chronological order.
|
|
42 |
*
|
|
43 |
* @author James Moger
|
|
44 |
*
|
|
45 |
*/
|
|
46 |
public class ActivityPanel extends BasePanel {
|
|
47 |
|
|
48 |
private static final long serialVersionUID = 1L;
|
|
49 |
|
|
50 |
public ActivityPanel(String wicketId, List<DailyActivity> recentActivity) {
|
|
51 |
super(wicketId);
|
|
52 |
|
|
53 |
Collections.sort(recentActivity);
|
|
54 |
|
|
55 |
DataView<DailyActivity> activityView = new DataView<DailyActivity>("activity",
|
|
56 |
new ListDataProvider<DailyActivity>(recentActivity)) {
|
|
57 |
private static final long serialVersionUID = 1L;
|
|
58 |
|
|
59 |
public void populateItem(final Item<DailyActivity> item) {
|
|
60 |
final DailyActivity entry = item.getModelObject();
|
|
61 |
item.add(WicketUtils.createDatestampLabel("title", entry.date, GitBlitWebSession
|
|
62 |
.get().getTimezone()));
|
|
63 |
|
|
64 |
// display the commits in chronological order
|
|
65 |
DataView<RepositoryCommit> commits = new DataView<RepositoryCommit>("commits",
|
|
66 |
new ListDataProvider<RepositoryCommit>(entry.commits)) {
|
|
67 |
private static final long serialVersionUID = 1L;
|
|
68 |
|
|
69 |
public void populateItem(final Item<RepositoryCommit> item) {
|
|
70 |
final RepositoryCommit commit = item.getModelObject();
|
|
71 |
Fragment fragment = new Fragment("commit", "commitFragment", this);
|
|
72 |
|
|
73 |
// time of day
|
|
74 |
fragment.add(WicketUtils.createTimeLabel("time", commit.getAuthorIdent()
|
|
75 |
.getWhen(), GitBlitWebSession.get().getTimezone()));
|
|
76 |
|
|
77 |
// avatar
|
|
78 |
fragment.add(new GravatarImage("avatar", commit.getAuthorIdent(), 36));
|
|
79 |
|
|
80 |
// merge icon
|
|
81 |
if (commit.getParentCount() > 1) {
|
|
82 |
fragment.add(WicketUtils.newImage("commitIcon",
|
|
83 |
"commit_merge_16x16.png"));
|
|
84 |
} else {
|
|
85 |
fragment.add(WicketUtils.newBlankImage("commitIcon"));
|
|
86 |
}
|
|
87 |
|
|
88 |
// author search link
|
|
89 |
String author = commit.getAuthorIdent().getName();
|
|
90 |
LinkPanel authorLink = new LinkPanel("author", "list", author,
|
|
91 |
SearchPage.class, WicketUtils.newSearchParameter(commit.repository,
|
|
92 |
commit.getName(), author, Constants.SearchType.AUTHOR));
|
|
93 |
setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);
|
|
94 |
fragment.add(authorLink);
|
|
95 |
|
|
96 |
// repository summary page link
|
|
97 |
LinkPanel repositoryLink = new LinkPanel("repository", "list",
|
|
98 |
commit.repository, SummaryPage.class,
|
|
99 |
WicketUtils.newRepositoryParameter(commit.repository));
|
|
100 |
fragment.add(repositoryLink);
|
|
101 |
|
|
102 |
// repository branch
|
|
103 |
LinkPanel branchLink = new LinkPanel("branch", "list", commit.branch,
|
|
104 |
LogPage.class, WicketUtils.newObjectParameter(commit.repository,
|
|
105 |
commit.branch));
|
|
106 |
WicketUtils.setCssStyle(branchLink, "color: #008000;");
|
|
107 |
fragment.add(branchLink);
|
|
108 |
|
|
109 |
LinkPanel commitid = new LinkPanel("commitid", "list subject",
|
|
110 |
commit.getShortName(), CommitPage.class,
|
|
111 |
WicketUtils.newObjectParameter(commit.repository, commit.getName()));
|
|
112 |
fragment.add(commitid);
|
|
113 |
|
|
114 |
// message/commit link
|
|
115 |
String shortMessage = commit.getShortMessage();
|
|
116 |
LinkPanel shortlog = new LinkPanel("message", "list subject", shortMessage,
|
|
117 |
CommitPage.class, WicketUtils.newObjectParameter(commit.repository,
|
|
118 |
commit.getName()));
|
|
119 |
fragment.add(shortlog);
|
|
120 |
|
|
121 |
// refs
|
|
122 |
fragment.add(new RefsPanel("commitRefs", commit.repository, commit
|
|
123 |
.getRefs()));
|
|
124 |
|
|
125 |
// view, diff, tree links
|
|
126 |
fragment.add(new BookmarkablePageLink<Void>("view", CommitPage.class,
|
|
127 |
WicketUtils.newObjectParameter(commit.repository, commit.getName())));
|
|
128 |
fragment.add(new BookmarkablePageLink<Void>("diff", CommitDiffPage.class,
|
|
129 |
WicketUtils.newObjectParameter(commit.repository, commit.getName()))
|
|
130 |
.setEnabled(commit.getParentCount() > 0));
|
|
131 |
fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class,
|
|
132 |
WicketUtils.newObjectParameter(commit.repository, commit.getName())));
|
|
133 |
|
|
134 |
item.add(fragment);
|
|
135 |
}
|
|
136 |
};
|
|
137 |
item.add(commits);
|
|
138 |
}
|
|
139 |
};
|
|
140 |
add(activityView);
|
|
141 |
}
|
|
142 |
}
|