From b01ca06b8d14634a2890590916450ef0e36f2b3a Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Sat, 18 Jun 2011 08:39:22 -0400 Subject: [PATCH] Mount parameters setting. --- src/com/gitblit/wicket/panels/BranchesPanel.java | 41 ++++++++++++++++++++++++++++++++++------- 1 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java index d50db88..302b48d 100644 --- a/src/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/com/gitblit/wicket/panels/BranchesPanel.java @@ -21,6 +21,8 @@ import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.link.ExternalLink; +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,6 +30,7 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; +import com.gitblit.SyndicationServlet; import com.gitblit.models.RefModel; import com.gitblit.models.RepositoryModel; import com.gitblit.utils.JGitUtils; @@ -35,6 +38,7 @@ import com.gitblit.wicket.WicketUtils; 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; @@ -42,15 +46,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); @@ -89,11 +95,25 @@ 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()))); + fragment.add(new ExternalLink("syndication", SyndicationServlet.asLink(getRequest() + .getRelativePathPrefixToContextRoot(), model.name, entry.getName(), 0))); + 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++; } @@ -105,5 +125,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