\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+import org.apache.wicket.markup.html.panel.Fragment;\r
import org.apache.wicket.markup.repeater.Item;\r
import org.apache.wicket.markup.repeater.data.DataView;\r
import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.models.PathModel;\r
import com.gitblit.wicket.pages.BlobDiffPage;\r
+import com.gitblit.wicket.pages.BlobPage;\r
import com.gitblit.wicket.pages.CommitDiffPage;\r
import com.gitblit.wicket.pages.CommitPage;\r
import com.gitblit.wicket.pages.HistoryPage;\r
import com.gitblit.wicket.pages.LogPage;\r
+import com.gitblit.wicket.pages.TreePage;\r
\r
public class HistoryPanel extends BasePanel {\r
\r
private static final long serialVersionUID = 1L;\r
- \r
+\r
private boolean hasMore = false;\r
\r
public HistoryPanel(String wicketId, final String repositoryName, final String objectId, final String path, Repository r, int limit, int pageOffset) {\r
if (itemsPerPage <= 1) {\r
itemsPerPage = 50;\r
}\r
- \r
- RevCommit commit = JGitUtils.getCommit(r, objectId); \r
+\r
+ RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ List<PathModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
+\r
+ PathModel matchingPath = null;\r
+ for (PathModel p : paths) {\r
+ if (p.path.equals(path)) {\r
+ matchingPath = p;\r
+ break;\r
+ }\r
+ }\r
+ final boolean isTree = matchingPath == null ? true : matchingPath.isTree();\r
+\r
final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);\r
List<RevCommit> commits;\r
if (pageResults) {\r
// Fixed size result set\r
commits = JGitUtils.getRevLog(r, objectId, path, 0, limit);\r
}\r
- \r
+\r
// inaccurate way to determine if there are more commits.\r
- // works unless commits.size() represents the exact end. \r
+ // works unless commits.size() represents the exact end.\r
hasMore = commits.size() >= itemsPerPage;\r
\r
// header\r
\r
item.add(new RefsPanel("commitRefs", repositoryName, entry, allRefs));\r
\r
- // TODO links for folder\r
- item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
- item.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
- item.add(new BookmarkablePageLink<Void>("difftocurrent", BlobDiffPage.class, WicketUtils.newBlobDiffParameter(repositoryName, entry.getName(), objectId, path)).setEnabled(counter > 0));\r
+ if (isTree) {\r
+ Fragment links = new Fragment("historyLinks", "treeLinks", this);\r
+ links.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+ links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+ item.add(links);\r
+ } else {\r
+ Fragment links = new Fragment("historyLinks", "blobLinks", this);\r
+ links.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, entry.getName(), path)));\r
+ links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+ links.add(new BookmarkablePageLink<Void>("difftocurrent", BlobDiffPage.class, WicketUtils.newBlobDiffParameter(repositoryName, entry.getName(), objectId, path)).setEnabled(counter > 0));\r
+ item.add(links);\r
+ }\r
\r
WicketUtils.setAlternatingBackground(item, counter);\r
counter++;\r
}\r
}\r
}\r
- \r
+\r
public boolean hasMore() {\r
return hasMore;\r
}\r