diff options
Diffstat (limited to 'src/main/java/com/gitblit/wicket/panels/NavigationPanel.java')
-rw-r--r-- | src/main/java/com/gitblit/wicket/panels/NavigationPanel.java | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java b/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java index 7db29fa2..2bc92f4c 100644 --- a/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java @@ -23,9 +23,11 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
-import com.gitblit.wicket.PageRegistration;
-import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration;
-import com.gitblit.wicket.PageRegistration.OtherPageLink;
+import com.gitblit.models.NavLink;
+import com.gitblit.models.NavLink.DropDownMenuNavLink;
+import com.gitblit.models.NavLink.DropDownPageMenuNavLink;
+import com.gitblit.models.NavLink.ExternalNavLink;
+import com.gitblit.models.NavLink.PageNavLink;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.BasePage;
@@ -34,52 +36,59 @@ public class NavigationPanel extends Panel { private static final long serialVersionUID = 1L;
public NavigationPanel(String id, final Class<? extends BasePage> pageClass,
- List<PageRegistration> registeredPages) {
+ List<NavLink> navLinks) {
super(id);
- ListDataProvider<PageRegistration> refsDp = new ListDataProvider<PageRegistration>(
- registeredPages);
- DataView<PageRegistration> refsView = new DataView<PageRegistration>("navLink", refsDp) {
+ ListDataProvider<NavLink> refsDp = new ListDataProvider<NavLink>(navLinks);
+ DataView<NavLink> linksView = new DataView<NavLink>("navLink", refsDp) {
private static final long serialVersionUID = 1L;
@Override
- public void populateItem(final Item<PageRegistration> item) {
- PageRegistration entry = item.getModelObject();
- String linkText = entry.translationKey;
+ public void populateItem(final Item<NavLink> item) {
+ NavLink navLink = item.getModelObject();
+ String linkText = navLink.translationKey;
try {
// try to lookup translation key
- linkText = getString(entry.translationKey);
+ linkText = getString(navLink.translationKey);
} catch (Exception e) {
}
- if (entry.hiddenPhone) {
+ if (navLink.hiddenPhone) {
WicketUtils.setCssClass(item, "hidden-phone");
}
- if (entry instanceof OtherPageLink) {
+ if (navLink instanceof ExternalNavLink) {
// other link
- OtherPageLink link = (OtherPageLink) entry;
+ ExternalNavLink link = (ExternalNavLink) navLink;
Component c = new LinkPanel("link", null, linkText, link.url);
c.setRenderBodyOnly(true);
item.add(c);
- } else if (entry instanceof DropDownMenuRegistration) {
+ } else if (navLink instanceof DropDownPageMenuNavLink) {
// drop down menu
- DropDownMenuRegistration reg = (DropDownMenuRegistration) entry;
+ DropDownPageMenuNavLink reg = (DropDownPageMenuNavLink) navLink;
Component c = new DropDownMenu("link", linkText, reg);
c.setRenderBodyOnly(true);
item.add(c);
WicketUtils.setCssClass(item, "dropdown");
- } else {
+ } else if (navLink instanceof DropDownMenuNavLink) {
+ // drop down menu
+ DropDownMenuNavLink reg = (DropDownMenuNavLink) navLink;
+ Component c = new DropDownMenu("link", linkText, reg);
+ c.setRenderBodyOnly(true);
+ item.add(c);
+ WicketUtils.setCssClass(item, "dropdown");
+ } else if (navLink instanceof PageNavLink) {
+ PageNavLink reg = (PageNavLink) navLink;
// standard page link
Component c = new LinkPanel("link", null, linkText,
- entry.pageClass, entry.params);
+ reg.pageClass, reg.params);
c.setRenderBodyOnly(true);
- if (entry.pageClass.equals(pageClass)) {
+ if (reg.pageClass.equals(pageClass)) {
WicketUtils.setCssClass(item, "active");
}
item.add(c);
}
}
};
- add(refsView);
+ add(linksView);
}
}
\ No newline at end of file |