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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.WicketUtils;
  20. import com.gitblit.wicket.panels.HistoryPanel;
  21. public class HistoryPage extends RepositoryPage {
  22. public HistoryPage(PageParameters params) {
  23. super(params);
  24. String path = WicketUtils.getPath(params);
  25. int pageNumber = WicketUtils.getPage(params);
  26. int prevPage = Math.max(0, pageNumber - 1);
  27. int nextPage = pageNumber + 1;
  28. HistoryPanel history = new HistoryPanel("historyPanel", repositoryName, objectId, path,
  29. getRepository(), -1, pageNumber - 1, getRepositoryModel().showRemoteBranches);
  30. boolean hasMore = history.hasMore();
  31. add(history);
  32. add(new BookmarkablePageLink<Void>("firstPageTop", HistoryPage.class,
  33. WicketUtils.newPathParameter(repositoryName, objectId, path))
  34. .setEnabled(pageNumber > 1));
  35. add(new BookmarkablePageLink<Void>("prevPageTop", HistoryPage.class,
  36. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage))
  37. .setEnabled(pageNumber > 1));
  38. add(new BookmarkablePageLink<Void>("nextPageTop", HistoryPage.class,
  39. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage))
  40. .setEnabled(hasMore));
  41. add(new BookmarkablePageLink<Void>("firstPageBottom", HistoryPage.class,
  42. WicketUtils.newPathParameter(repositoryName, objectId, path))
  43. .setEnabled(pageNumber > 1));
  44. add(new BookmarkablePageLink<Void>("prevPageBottom", HistoryPage.class,
  45. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage))
  46. .setEnabled(pageNumber > 1));
  47. add(new BookmarkablePageLink<Void>("nextPageBottom", HistoryPage.class,
  48. WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage))
  49. .setEnabled(hasMore));
  50. }
  51. @Override
  52. protected String getPageName() {
  53. return getString("gb.history");
  54. }
  55. }