Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

TreePage.java 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package com.gitblit.wicket.pages;
  2. import java.util.List;
  3. import org.apache.wicket.PageParameters;
  4. import org.apache.wicket.markup.html.basic.Label;
  5. import org.apache.wicket.markup.html.link.BookmarkablePageLink;
  6. import org.apache.wicket.markup.html.panel.Fragment;
  7. import org.apache.wicket.markup.repeater.Item;
  8. import org.apache.wicket.markup.repeater.data.DataView;
  9. import org.apache.wicket.markup.repeater.data.ListDataProvider;
  10. import org.eclipse.jgit.lib.Constants;
  11. import org.eclipse.jgit.lib.Repository;
  12. import org.eclipse.jgit.revwalk.RevCommit;
  13. import com.gitblit.utils.ByteFormat;
  14. import com.gitblit.utils.JGitUtils;
  15. import com.gitblit.wicket.LinkPanel;
  16. import com.gitblit.wicket.RepositoryPage;
  17. import com.gitblit.wicket.WicketUtils;
  18. import com.gitblit.wicket.models.PathModel;
  19. import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
  20. public class TreePage extends RepositoryPage {
  21. public TreePage(PageParameters params) {
  22. super(params);
  23. final String path = WicketUtils.getPath(params);
  24. Repository r = getRepository();
  25. RevCommit commit = JGitUtils.getCommit(r, objectId);
  26. List<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);
  27. // tree page links
  28. add(new Label("historyLink", getString("gb.history")));
  29. add(new BookmarkablePageLink<Void>("headLink", TreePage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));
  30. add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));
  31. // breadcrumbs
  32. add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));
  33. if (path != null && path.trim().length() > 0) {
  34. paths.add(0, PathModel.getParentPath(path, objectId));
  35. }
  36. final ByteFormat byteFormat = new ByteFormat();
  37. // changed paths list
  38. ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
  39. DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
  40. private static final long serialVersionUID = 1L;
  41. int counter = 0;
  42. public void populateItem(final Item<PathModel> item) {
  43. PathModel entry = item.getModelObject();
  44. item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
  45. if (entry.isParentPath) {
  46. // parent .. path
  47. item.add(new Label("pathSize", ""));
  48. item.add(new LinkPanel("pathName", null, entry.name, TreePage.class, newPathParameter(entry.path)));
  49. item.add(new Label("pathLinks", ""));
  50. } else {
  51. if (entry.isTree()) {
  52. // folder/tree link
  53. item.add(new Label("pathSize", ""));
  54. item.add(new LinkPanel("pathName", null, entry.name, TreePage.class, newPathParameter(entry.path)));
  55. // links
  56. Fragment links = new Fragment("pathLinks", "treeLinks", this);
  57. links.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));
  58. links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));
  59. item.add(links);
  60. } else {
  61. // blob link
  62. item.add(new Label("pathSize", byteFormat.format(entry.size)));
  63. item.add(new LinkPanel("pathName", "list", entry.name, BlobPage.class, newPathParameter(entry.path)));
  64. // links
  65. Fragment links = new Fragment("pathLinks", "blobLinks", this);
  66. links.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));
  67. links.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));
  68. links.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));
  69. links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));
  70. item.add(links);
  71. }
  72. }
  73. WicketUtils.setAlternatingBackground(item, counter);
  74. counter++;
  75. }
  76. };
  77. add(pathsView);
  78. }
  79. @Override
  80. protected String getPageName() {
  81. return getString("gb.tree");
  82. }
  83. }