From: James Moger Date: Mon, 11 Apr 2011 13:39:15 +0000 (-0400) Subject: Refactored more link panels into fragments. X-Git-Tag: v0.5.0~97 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1a3fc5e8f150ff73be27c67006a10bbab0c585b4;p=gitblit.git Refactored more link panels into fragments. --- diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index a16ea74c..1d7e7bab 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -37,4 +37,5 @@ gb.commitdiff = commitdiff gb.ticgit = ticgit gb.pageFirst = first gb.pagePrevious prev -gb.pageNext = next \ No newline at end of file +gb.pageNext = next +gb.parent = parent \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/CommitPage.html b/src/com/gitblit/wicket/pages/CommitPage.html index e49cd576..e3434c45 100644 --- a/src/com/gitblit/wicket/pages/CommitPage.html +++ b/src/com/gitblit/wicket/pages/CommitPage.html @@ -12,7 +12,7 @@ diff --git a/src/com/gitblit/wicket/pages/CommitPage.java b/src/com/gitblit/wicket/pages/CommitPage.java index b0a92b06..7de03457 100644 --- a/src/com/gitblit/wicket/pages/CommitPage.java +++ b/src/com/gitblit/wicket/pages/CommitPage.java @@ -9,6 +9,7 @@ import org.apache.wicket.markup.html.link.BookmarkablePageLink; 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.apache.wicket.model.StringResourceModel; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; @@ -25,10 +26,8 @@ public class CommitPage extends RepositoryPage { public CommitPage(PageParameters params) { super(params); - final String commitId = params.getString("h", ""); - Repository r = getRepository(); - RevCommit c = JGitUtils.getCommit(r, commitId); + RevCommit c = JGitUtils.getCommit(r, objectId); List parents = new ArrayList(); if (c.getParentCount() > 0) { @@ -40,8 +39,10 @@ public class CommitPage extends RepositoryPage { // commit page links if (parents.size() == 0) { add(new Label("parentLink", "none")); + add(new Label("commitdiffLink", getString("gb.commitdiff"))); } else { add(new LinkPanel("parentLink", null, parents.get(0).substring(0, 8), CommitPage.class, newCommitParameter(parents.get(0)))); + add(new LinkPanel("commitdiffLink", null, new StringResourceModel("gb.commitdiff", this, null), DiffPage.class, WicketUtils.newObjectParameter(repositoryName, objectId))); } add(new Label("patchLink", getString("gb.patch"))); diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.html b/src/com/gitblit/wicket/pages/RepositoriesPage.html index 5a84ee29..9bcb9b80 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.html +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.html @@ -26,6 +26,13 @@ + + + + + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java index 83d67520..47d45122 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -10,6 +10,8 @@ import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder import org.apache.wicket.extensions.markup.html.repeater.util.SortParam; import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; 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.model.IModel; @@ -22,7 +24,6 @@ import com.gitblit.wicket.GitBlitWebApp; import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.models.RepositoryModel; -import com.gitblit.wicket.panels.AdminLinksPanel; public class RepositoriesPage extends BasePage { @@ -31,7 +32,10 @@ public class RepositoriesPage extends BasePage { super(); setupPage("", ""); - add(new AdminLinksPanel("adminPanel").setVisible(StoredSettings.getBoolean("allowAdministration", false))); + Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this); + adminLinks.add(new BookmarkablePageLink("newRepository", RepositoriesPage.class)); + adminLinks.add(new BookmarkablePageLink("newUser", RepositoriesPage.class)); + add(adminLinks.setVisible(StoredSettings.getBoolean("allowAdministration", false))); add(new Label("repositoriesMessage", StoredSettings.getString("repositoriesMessage", "")).setEscapeModelStrings(false)); diff --git a/src/com/gitblit/wicket/pages/TreePage.html b/src/com/gitblit/wicket/pages/TreePage.html index 2bfbb992..3eda96b7 100644 --- a/src/com/gitblit/wicket/pages/TreePage.html +++ b/src/com/gitblit/wicket/pages/TreePage.html @@ -27,10 +27,24 @@ [path size] [path permissions] - [path links] + [path links] + + + + + + + + + + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/TreePage.java b/src/com/gitblit/wicket/pages/TreePage.java index 493313ee..e24033e4 100644 --- a/src/com/gitblit/wicket/pages/TreePage.java +++ b/src/com/gitblit/wicket/pages/TreePage.java @@ -4,6 +4,8 @@ import java.util.List; import org.apache.wicket.PageParameters; 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; @@ -17,8 +19,6 @@ import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.models.PathModel; import com.gitblit.wicket.panels.PathBreadcrumbsPanel; -import com.gitblit.wicket.panels.TreeBlobLinksPanel; -import com.gitblit.wicket.panels.TreeLinksPanel; public class TreePage extends RepositoryPage { @@ -59,22 +59,32 @@ public class TreePage extends RepositoryPage { // parent .. path item.add(new Label("pathSize", "")); item.add(new LinkPanel("pathName", null, entry.name, TreePage.class, newPathParameter(entry.path))); - item.add(new Label("treeLinks", "")); + item.add(new Label("pathLinks", "")); } else { if (entry.isTree()) { // folder/tree link item.add(new Label("pathSize", "")); item.add(new LinkPanel("pathName", null, entry.name, TreePage.class, newPathParameter(entry.path))); - item.add(new TreeLinksPanel("treeLinks", repositoryName, entry)); + + // links + Fragment links = new Fragment("pathLinks", "treeLinks", this); + links.add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path))); + links.add(new BookmarkablePageLink("history", TreePage.class).setEnabled(false)); + item.add(links); } else { // blob link item.add(new Label("pathSize", byteFormat.format(entry.size))); item.add(new LinkPanel("pathName", "list", entry.name, BlobPage.class, newPathParameter(entry.path))); - item.add(new TreeBlobLinksPanel("treeLinks", repositoryName, entry)); + + // links + Fragment links = new Fragment("pathLinks", "blobLinks", this); + links.add(new BookmarkablePageLink("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path))); + links.add(new BookmarkablePageLink("raw", BlobPage.class).setEnabled(false)); + links.add(new BookmarkablePageLink("history", BlobPage.class).setEnabled(false)); + item.add(links); } } - String clazz = counter % 2 == 0 ? "dark" : "light"; - WicketUtils.setCssClass(item, clazz); + WicketUtils.setAlternatingBackground(item, counter); counter++; } }; diff --git a/src/com/gitblit/wicket/panels/AdminLinksPanel.html b/src/com/gitblit/wicket/panels/AdminLinksPanel.html deleted file mode 100644 index 9e128233..00000000 --- a/src/com/gitblit/wicket/panels/AdminLinksPanel.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/AdminLinksPanel.java b/src/com/gitblit/wicket/panels/AdminLinksPanel.java deleted file mode 100644 index 3199447a..00000000 --- a/src/com/gitblit/wicket/panels/AdminLinksPanel.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.markup.html.panel.Panel; - -import com.gitblit.wicket.pages.RepositoriesPage; - -public class AdminLinksPanel extends Panel { - - private static final long serialVersionUID = 1L; - - public AdminLinksPanel(String id) { - super(id); - - add(new BookmarkablePageLink("newRepository", RepositoriesPage.class)); - add(new BookmarkablePageLink("newUser", RepositoriesPage.class)); - } -} \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java index d27133ce..974fb9a0 100644 --- a/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java +++ b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java @@ -20,7 +20,7 @@ public class PathBreadcrumbsPanel extends Panel { private final String ROOT = "--ROOT--"; - public PathBreadcrumbsPanel(String id, final String repositoryName, String pathName, final String commitId) { + public PathBreadcrumbsPanel(String id, final String repositoryName, String pathName, final String objectId) { super(id); List crumbs = new ArrayList(); crumbs.add(new BreadCrumb("[" + repositoryName + "]", ROOT, false)); @@ -44,13 +44,13 @@ public class PathBreadcrumbsPanel extends Panel { public void populateItem(final Item item) { final BreadCrumb entry = item.getModelObject(); String path = entry.getPath(); - String parameters = "p=" + repositoryName + ",h=" + commitId; - if (path != null) { - parameters += ",f=" + path; + if (entry.isLeaf) { + item.add(new Label("pathLink", entry.name)); + item.add(new Label("pathSeparator", "").setVisible(false)); + } else { + item.add(new LinkPanel("pathLink", null, entry.name, TreePage.class, WicketUtils.newPathParameter(repositoryName, objectId, path))); + item.add(new Label("pathSeparator", "/")); } - - item.add(new LinkPanel("pathLink", null, entry.name, TreePage.class, WicketUtils.newPathParameter(repositoryName, commitId, path))); - item.add(new Label("pathSeparator", entry.isLeaf ? "" : "/")); } }; add(pathsView); diff --git a/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.html b/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.html deleted file mode 100644 index 9f5c6a71..00000000 --- a/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.java b/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.java deleted file mode 100644 index e1e6f795..00000000 --- a/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.markup.html.panel.Panel; - -import com.gitblit.wicket.WicketUtils; -import com.gitblit.wicket.models.PathModel; -import com.gitblit.wicket.pages.BlobPage; - - -public class TreeBlobLinksPanel extends Panel { - - private static final long serialVersionUID = 1L; - - public TreeBlobLinksPanel(String id, String repositoryName, PathModel path) { - super(id); - add(new BookmarkablePageLink("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, path.commitId, path.path))); - add(new BookmarkablePageLink("raw", BlobPage.class).setEnabled(false)); - add(new BookmarkablePageLink("history", BlobPage.class).setEnabled(false)); - } -} \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TreeLinksPanel.html b/src/com/gitblit/wicket/panels/TreeLinksPanel.html deleted file mode 100644 index 69f3decb..00000000 --- a/src/com/gitblit/wicket/panels/TreeLinksPanel.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TreeLinksPanel.java b/src/com/gitblit/wicket/panels/TreeLinksPanel.java deleted file mode 100644 index 4965004a..00000000 --- a/src/com/gitblit/wicket/panels/TreeLinksPanel.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.markup.html.panel.Panel; - -import com.gitblit.wicket.WicketUtils; -import com.gitblit.wicket.models.PathModel; -import com.gitblit.wicket.pages.TreePage; - - -public class TreeLinksPanel extends Panel { - - private static final long serialVersionUID = 1L; - - public TreeLinksPanel(String id, String repositoryName, PathModel path) { - super(id); - add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newPathParameter(repositoryName, path.commitId, path.path))); - add(new BookmarkablePageLink("history", TreePage.class).setEnabled(false)); - } -} \ No newline at end of file