diff options
author | James Moger <james.moger@gitblit.com> | 2011-04-04 09:10:51 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-04-04 09:10:51 -0400 |
commit | 5fe7df81eb38dc66f2cfc4bf1973863a19f55cf2 (patch) | |
tree | 3f1b1b3f953aa8a5ed60e149043598fbdaf4d42f /src/com/gitblit/wicket/panels/RefsPanel.java | |
download | gitblit-5fe7df81eb38dc66f2cfc4bf1973863a19f55cf2.tar.gz gitblit-5fe7df81eb38dc66f2cfc4bf1973863a19f55cf2.zip |
Initial import of Git:Blit.
Change-Id: Ifce000c85c8947c3a768e782c841e41a8953d314
Diffstat (limited to 'src/com/gitblit/wicket/panels/RefsPanel.java')
-rw-r--r-- | src/com/gitblit/wicket/panels/RefsPanel.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/com/gitblit/wicket/panels/RefsPanel.java b/src/com/gitblit/wicket/panels/RefsPanel.java new file mode 100644 index 00000000..5dec57fe --- /dev/null +++ b/src/com/gitblit/wicket/panels/RefsPanel.java @@ -0,0 +1,66 @@ +package com.gitblit.wicket.panels;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.wicket.Component;
+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.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.WicketUtils;
+
+
+public class RefsPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public RefsPanel(String id, Repository r, RevCommit c) {
+ this(id, c, JGitUtils.getAllRefs(r));
+ }
+
+ public RefsPanel(String id, RevCommit c, Map<ObjectId, List<String>> refs) {
+ super(id);
+ List<String> refNames = refs.get(c.getId());
+ if (refNames == null) {
+ refNames = new ArrayList<String>();
+ }
+ Collections.sort(refNames);
+ ListDataProvider<String> refsDp = new ListDataProvider<String>(refNames);
+ DataView<String> refsView = new DataView<String>("ref", refsDp) {
+ private static final long serialVersionUID = 1L;
+ public void populateItem(final Item<String> item) {
+ String entry = item.getModelObject();
+ Component c = null;
+ if (entry.startsWith(Constants.R_HEADS)) {
+ // local head
+ c = new Label("refName", entry.substring(Constants.R_HEADS.length()));
+ WicketUtils.setCssClass(c, "head");
+ } else if (entry.startsWith(Constants.R_REMOTES)) {
+ // remote head
+ c = new Label("refName", entry.substring(Constants.R_REMOTES.length()));
+ WicketUtils.setCssClass(c, "ref");
+ } else if (entry.startsWith(Constants.R_TAGS)) {
+ // tag
+ c = new Label("refName", entry.substring(Constants.R_TAGS.length()));
+ WicketUtils.setCssClass(c, "tag");
+ } else {
+ // other
+ c = new Label("refName", entry);
+ }
+ WicketUtils.setHtmlTitle(c, entry);
+ item.add(c);
+ }
+ };
+ add(refsView);
+ }
+}
\ No newline at end of file |