James Moger
2013-09-18 0250286553ca93406bfaa976d6aae61e76a9d55f
src/main/java/com/gitblit/wicket/panels/RefsPanel.java
@@ -15,6 +15,7 @@
 */
package com.gitblit.wicket.panels;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -22,26 +23,27 @@
import java.util.Map;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.Constants;
import com.gitblit.models.RefModel;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.CommitPage;
import com.gitblit.wicket.pages.LogPage;
import com.gitblit.wicket.pages.RepositoryPage;
import com.gitblit.wicket.pages.TagPage;
public class RefsPanel extends Panel {
   private static final long serialVersionUID = 1L;
   public RefsPanel(String id, final String repositoryName, RevCommit c,
         Map<ObjectId, List<RefModel>> refs) {
      this(id, repositoryName, refs.get(c.getId()));
@@ -97,8 +99,9 @@
            String name = entry.displayName;
            String objectid = entry.getReferencedObjectId().getName();
            boolean breakLine = false;
            Class<? extends RepositoryPage> linkClass = CommitPage.class;
            Class<? extends WebPage> linkClass = CommitPage.class;
            String cssClass = "";
            String tooltip = "";
            if (name.startsWith(Constants.R_HEADS)) {
               // local branch
               linkClass = LogPage.class;
@@ -108,6 +111,22 @@
               // local head
               linkClass = LogPage.class;
               cssClass = "headRef";
            } else if (name.startsWith(Constants.R_CHANGES)) {
               // Gerrit change ref
               name = name.substring(Constants.R_CHANGES.length());
               // strip leading nn/ from nn/#####nn/ps = #####nn-ps
               name = name.substring(name.indexOf('/') + 1).replace('/', '-');
               String [] values = name.split("-");
               tooltip = MessageFormat.format(getString("gb.reviewPatchset"), values[0], values[1]);
               cssClass = "otherRef";
            } else if (name.startsWith(Constants.R_PULL)) {
               // Pull Request ref
               name = "pull #" + name.substring(Constants.R_PULL.length());
               if (name.endsWith("/head")) {
                  // strip pull request head from name
                  name = name.substring(0, name.length() - "/head".length());
               }
               cssClass = "pullRef";
            } else if (name.startsWith(Constants.R_REMOTES)) {
               // remote branch
               linkClass = LogPage.class;
@@ -142,7 +161,11 @@
            Component c = new LinkPanel("refName", null, name, linkClass,
                  WicketUtils.newObjectParameter(repositoryName, objectid));
            WicketUtils.setCssClass(c, cssClass);
            WicketUtils.setHtmlTooltip(c, name);
            if (StringUtils.isEmpty(tooltip)) {
               WicketUtils.setHtmlTooltip(c, name);
            } else {
               WicketUtils.setHtmlTooltip(c, tooltip);
            }
            item.add(c);
            Label lb = new Label("lineBreak", "<br/>");
            lb.setVisible(breakLine);