]> source.dussan.org Git - gitblit.git/commitdiff
Finished history tree/blob links.
authorJames Moger <james.moger@gitblit.com>
Sun, 17 Apr 2011 20:57:41 +0000 (16:57 -0400)
committerJames Moger <james.moger@gitblit.com>
Sun, 17 Apr 2011 20:57:41 +0000 (16:57 -0400)
src/com/gitblit/wicket/panels/HistoryPanel.html
src/com/gitblit/wicket/panels/HistoryPanel.java

index 9ba95de4486c0593cd36822bcb641d2bad44fd65..3f120e22e71b0825c05c9e8127f3ed26a3cf3f81 100644 (file)
                        <td><div wicket:id="commitShortMessage">[commit short message]</div></td>\r
                        <td class="rightAlign"><div wicket:id="commitRefs">[commit refs]</div></td>                     \r
                        <td class="rightAlign">\r
-                               <span class="link">\r
-                                               <a wicket:id="view"><wicket:message key="gb.view"></wicket:message></a> | <a wicket:id="commitdiff"><wicket:message key="gb.commitdiff"></wicket:message></a> | <a wicket:id="difftocurrent"><wicket:message key="gb.difftocurrent"></wicket:message></a>\r
-                                       </span>\r
+                               <span wicket:id="historyLinks">[history links]</span>\r
                                </td>\r
                        </tr>\r
        </tbody>\r
        </table>        \r
        <div wicket:id="moreHistory">[more...]</div>\r
        \r
+       <!--  tree links -->\r
+       <wicket:fragment wicket:id="treeLinks">\r
+               <span class="link">\r
+                       <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> | <a wicket:id="commitdiff"><wicket:message key="gb.commitdiff"></wicket:message></a>\r
+               </span>\r
+       </wicket:fragment>\r
+       \r
+       <!-- blob links -->\r
+       <wicket:fragment wicket:id="blobLinks">\r
+               <span class="link">\r
+                       <a wicket:id="view"><wicket:message key="gb.view"></wicket:message></a> | <a wicket:id="commitdiff"><wicket:message key="gb.commitdiff"></wicket:message></a> | <a wicket:id="difftocurrent"><wicket:message key="gb.difftocurrent"></wicket:message></a>\r
+               </span> \r
+       </wicket:fragment>\r
+       \r
 </wicket:panel>\r
 </body>\r
 </html>
\ No newline at end of file
index 855128b0d264764c087f60707314f2a369e65c16..00f4d53364640036a661d1111483831a1707cb95 100644 (file)
@@ -6,6 +6,7 @@ import java.util.Map;
 \r
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.apache.wicket.markup.repeater.Item;\r
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
@@ -20,16 +21,19 @@ import com.gitblit.utils.JGitUtils;
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.LinkPanel;\r
 import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.models.PathModel;\r
 import com.gitblit.wicket.pages.BlobDiffPage;\r
+import com.gitblit.wicket.pages.BlobPage;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.HistoryPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
+import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class HistoryPanel extends BasePanel {\r
 \r
        private static final long serialVersionUID = 1L;\r
-       \r
+\r
        private boolean hasMore = false;\r
 \r
        public HistoryPanel(String wicketId, final String repositoryName, final String objectId, final String path, Repository r, int limit, int pageOffset) {\r
@@ -39,8 +43,19 @@ public class HistoryPanel extends BasePanel {
                if (itemsPerPage <= 1) {\r
                        itemsPerPage = 50;\r
                }\r
-               \r
-               RevCommit commit = JGitUtils.getCommit(r, objectId);            \r
+\r
+               RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+               List<PathModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
+\r
+               PathModel matchingPath = null;\r
+               for (PathModel p : paths) {\r
+                       if (p.path.equals(path)) {\r
+                               matchingPath = p;\r
+                               break;\r
+                       }\r
+               }\r
+               final boolean isTree = matchingPath == null ? true : matchingPath.isTree();\r
+\r
                final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);\r
                List<RevCommit> commits;\r
                if (pageResults) {\r
@@ -50,9 +65,9 @@ public class HistoryPanel extends BasePanel {
                        // Fixed size result set\r
                        commits = JGitUtils.getRevLog(r, objectId, path, 0, limit);\r
                }\r
-               \r
+\r
                // inaccurate way to determine if there are more commits.\r
-               // works unless commits.size() represents the exact end. \r
+               // works unless commits.size() represents the exact end.\r
                hasMore = commits.size() >= itemsPerPage;\r
 \r
                // header\r
@@ -93,10 +108,18 @@ public class HistoryPanel extends BasePanel {
 \r
                                item.add(new RefsPanel("commitRefs", repositoryName, entry, allRefs));\r
 \r
-                               // TODO links for folder\r
-                               item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
-                               item.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
-                               item.add(new BookmarkablePageLink<Void>("difftocurrent", BlobDiffPage.class, WicketUtils.newBlobDiffParameter(repositoryName, entry.getName(), objectId, path)).setEnabled(counter > 0));\r
+                               if (isTree) {\r
+                                       Fragment links = new Fragment("historyLinks", "treeLinks", this);\r
+                                       links.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+                                       links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+                                       item.add(links);\r
+                               } else {\r
+                                       Fragment links = new Fragment("historyLinks", "blobLinks", this);\r
+                                       links.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, entry.getName(), path)));\r
+                                       links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+                                       links.add(new BookmarkablePageLink<Void>("difftocurrent", BlobDiffPage.class, WicketUtils.newBlobDiffParameter(repositoryName, entry.getName(), objectId, path)).setEnabled(counter > 0));\r
+                                       item.add(links);\r
+                               }\r
 \r
                                WicketUtils.setAlternatingBackground(item, counter);\r
                                counter++;\r
@@ -124,7 +147,7 @@ public class HistoryPanel extends BasePanel {
                        }\r
                }\r
        }\r
-       \r
+\r
        public boolean hasMore() {\r
                return hasMore;\r
        }\r