Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

CommitLegendPanel.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package com.gitblit.wicket.panels;
  2. import java.text.MessageFormat;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Map;
  6. import java.util.concurrent.atomic.AtomicInteger;
  7. import org.apache.wicket.markup.html.basic.Label;
  8. import org.apache.wicket.markup.html.panel.Panel;
  9. import org.apache.wicket.markup.repeater.Item;
  10. import org.apache.wicket.markup.repeater.data.DataView;
  11. import org.apache.wicket.markup.repeater.data.ListDataProvider;
  12. import org.eclipse.jgit.diff.DiffEntry.ChangeType;
  13. import com.gitblit.utils.JGitUtils;
  14. import com.gitblit.wicket.WicketUtils;
  15. import com.gitblit.wicket.models.PathModel.PathChangeModel;
  16. public class CommitLegendPanel extends Panel {
  17. private static final long serialVersionUID = 1L;
  18. public CommitLegendPanel(String id, List<PathChangeModel> paths) {
  19. super(id);
  20. final Map<ChangeType, AtomicInteger> stats = JGitUtils.getChangedPathsStats(paths);
  21. ListDataProvider<ChangeType> legendDp = new ListDataProvider<ChangeType>(new ArrayList<ChangeType>(stats.keySet()));
  22. DataView<ChangeType> legendsView = new DataView<ChangeType>("legend", legendDp) {
  23. private static final long serialVersionUID = 1L;
  24. public void populateItem(final Item<ChangeType> item) {
  25. ChangeType entry = item.getModelObject();
  26. Label changeType = new Label("changeType", "");
  27. WicketUtils.setChangeTypeCssClass(changeType, entry);
  28. item.add(changeType);
  29. int count = stats.get(entry).intValue();
  30. String description = "";
  31. switch(entry) {
  32. case ADD:
  33. description = MessageFormat.format(getString("gb.filesAdded"), count);
  34. break;
  35. case MODIFY:
  36. description = MessageFormat.format(getString("gb.filesModified"), count);
  37. break;
  38. case DELETE:
  39. description = MessageFormat.format(getString("gb.filesDeleted"), count);
  40. break;
  41. case COPY:
  42. description = MessageFormat.format(getString("gb.filesCopied"), count);
  43. break;
  44. case RENAME:
  45. description = MessageFormat.format(getString("gb.filesRenamed"), count);
  46. break;
  47. }
  48. item.add(new Label("description", description));
  49. }
  50. };
  51. add(legendsView);
  52. }
  53. }