From f339f5de2ee6d354f55e14e9340bebc4611535b3 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 09 Jun 2011 19:04:24 -0400
Subject: [PATCH] Unit testing. Documentation. Simplified settings classes.
---
src/com/gitblit/wicket/panels/BranchesPanel.java | 42 ++++++++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java
index 357c7c2..b11c03a 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.java
@@ -21,6 +21,7 @@
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
@@ -28,14 +29,14 @@
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
+import com.gitblit.models.RefModel;
+import com.gitblit.models.RepositoryModel;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
-import com.gitblit.wicket.LinkPanel;
import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.models.RefModel;
-import com.gitblit.wicket.models.RepositoryModel;
import com.gitblit.wicket.pages.BranchesPage;
import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.MetricsPage;
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TreePage;
@@ -43,15 +44,17 @@
private static final long serialVersionUID = 1L;
+ private final boolean hasBranches;
+
public BranchesPanel(String wicketId, final RepositoryModel model, Repository r,
final int maxCount) {
super(wicketId);
// branches
List<RefModel> branches = new ArrayList<RefModel>();
- branches.addAll(JGitUtils.getLocalBranches(r, maxCount));
+ branches.addAll(JGitUtils.getLocalBranches(r, false, maxCount));
if (model.showRemoteBranches) {
- branches.addAll(JGitUtils.getRemoteBranches(r, maxCount));
+ branches.addAll(JGitUtils.getRemoteBranches(r, false, maxCount));
}
Collections.sort(branches);
Collections.reverse(branches);
@@ -90,11 +93,23 @@
item.add(new Label("branchType", remote ? getString("gb.remote")
: getString("gb.local")).setVisible(maxCount <= 0));
- item.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
- item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
-
+ if (maxCount <= 0) {
+ Fragment fragment = new Fragment("branchLinks", "branchPageLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,
+ WicketUtils.newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ } else {
+ Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ }
WicketUtils.setAlternatingBackground(item, counter);
counter++;
}
@@ -106,5 +121,12 @@
add(new LinkPanel("allBranches", "link", new StringResourceModel("gb.allBranches",
this, null), BranchesPage.class, WicketUtils.newRepositoryParameter(model.name)));
}
+ // We always have 1 branch
+ hasBranches = branches.size() > 1;
+ }
+
+ public BranchesPanel hideIfEmpty() {
+ setVisible(hasBranches);
+ return this;
}
}
--
Gitblit v1.9.1