You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HistoryPage.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  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.pages;
  17. import org.apache.wicket.PageParameters;
  18. import org.apache.wicket.markup.html.link.BookmarkablePageLink;
  19. import com.gitblit.wicket.CacheControl;
  20. import com.gitblit.wicket.WicketUtils;
  21. import com.gitblit.wicket.CacheControl.LastModified;
  22. import com.gitblit.wicket.panels.HistoryPanel;
  23. @CacheControl(LastModified.REPOSITORY)
  24. public class HistoryPage extends RepositoryPage {
  25. public HistoryPage(PageParameters params) {
  26. super(params);
  27. String path = WicketUtils.getPath(params);
  28. int pageNumber = WicketUtils.getPage(params);
  29. int prevPage = Math.max(0, pageNumber - 1);
  30. int nextPage = pageNumber + 1;
  31. HistoryPanel history = new HistoryPanel("historyPanel", repositoryName, objectId, path,
  32. getRepository(), -1, pageNumber - 1, getRepositoryModel().showRemoteBranches);
  33. boolean hasMore = history.hasMore();
  34. add(history);
  35. add(new BookmarkablePageLink<Void>("firstPageTop", HistoryPage.class,
  36. WicketUtils.newPathParameter(repositoryName, objectId, path))
  37. .setEnabled(pageNumber > 1));
  38. add(new BookmarkablePageLink<Void>("prevPageTop", HistoryPage.class,
  39. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage))
  40. .setEnabled(pageNumber > 1));
  41. add(new BookmarkablePageLink<Void>("nextPageTop", HistoryPage.class,
  42. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage))
  43. .setEnabled(hasMore));
  44. add(new BookmarkablePageLink<Void>("firstPageBottom", HistoryPage.class,
  45. WicketUtils.newPathParameter(repositoryName, objectId, path))
  46. .setEnabled(pageNumber > 1));
  47. add(new BookmarkablePageLink<Void>("prevPageBottom", HistoryPage.class,
  48. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage))
  49. .setEnabled(pageNumber > 1));
  50. add(new BookmarkablePageLink<Void>("nextPageBottom", HistoryPage.class,
  51. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage))
  52. .setEnabled(hasMore));
  53. }
  54. @Override
  55. protected String getPageName() {
  56. return getString("gb.history");
  57. }
  58. @Override
  59. protected Class<? extends BasePage> getRepoNavPageClass() {
  60. return TreePage.class;
  61. }
  62. }