MarkupContainer htmlRootElement = new TransparentWebMarkupContainer("htmlRootElement");
htmlRootElement.add(AttributeAppender.append("lang", MavenArtifactNotifierSession.get().getLocale().getLanguage()));
add(htmlRootElement);
MarkupContainer bodyElement = new TransparentWebMarkupContainer("bodyElement");
bodyElement.add(new ClassAttributeAppender(new LoadableDetachableModel<String>() {
private static final long serialVersionUID = 1L;
@Override
protected String load() {
StringBuilder cssClassesSb = new StringBuilder();
for (String cssClasse : bodyCssClasses) {
cssClassesSb.append(cssClasse).append(" ");
}
return cssClassesSb.toString();
}
}));
add(bodyElement);
add(new AnimatedGlobalFeedbackPanel("animatedGlobalFeedbackPanel"));
addHeadPageTitlePrependedElement(new BreadCrumbElement(new ResourceModel("common.rootPageTitle")));
add(createHeadPageTitle("headPageTitle"));
Link<Void> homePageLink = MavenArtifactNotifierApplication.get().getHomePageLinkDescriptor().link("homePageLink");
if (HomePage.class.equals(getClass())) {
homePageLink.setBeforeDisabledLink("");
homePageLink.setAfterDisabledLink("");
homePageLink.setEnabled(false);
} else {
homePageLink.add(new AttributeAppender("title", new ResourceModel("navigation.backToHome")));
}
add(homePageLink);
// Bread crumb
add(createBodyBreadCrumb("breadCrumb"));
// Main navigation bar
add(new ListView<NavigationMenuItem>("mainNav", getMainNav()) {
private static final long serialVersionUID = -2257358650754295013L;
@Override
protected void populateItem(ListItem<NavigationMenuItem> item) {
NavigationMenuItem navItem = item.getModelObject();
AbstractLink navLink = navItem.link("navLink");
navLink.add(new Label("navLabel", navItem.getLabelModel()));
item.setVisible(navItem.isAccessible());
if (navItem.isActive(MainTemplate.this.getFirstMenuPage())) {
item.add(new ClassAttributeAppender("active"));
}
item.add(navLink);
// Dropdown
List<NavigationMenuItem> subMenuItems = navItem.getSubMenuItems();
WebMarkupContainer caret = new WebMarkupContainer("caret");
navLink.add(caret);
WebMarkupContainer dropdownMenu = new ListView<NavigationMenuItem>("dropdownMenu", subMenuItems) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<NavigationMenuItem> subMenuItem) {
NavigationMenuItem subMenu = subMenuItem.getModelObject();
AbstractLink navLink = subMenu.link("subMenuLink");
navLink.add(new Label("subMenuLabel", subMenu.getLabelModel()));
subMenuItem.setVisible(subMenu.isAccessible());
subMenuItem.add(navLink);
}
};
item.add(dropdownMenu);
if (!subMenuItems.isEmpty()) {
item.add(new ClassAttributeAppender("dropdown"));
navLink.add(new ClassAttributeAppender("dropdown-toggle"));
navLink.add(new AttributeAppender("data-toggle", "dropdown"));
navLink.add(new AttributeModifier("href", "#"));
caret.setVisible(true);
dropdownMenu.setVisible(true);
} else {
caret.setVisible(false);
dropdownMenu.setVisible(false);
}
}
});
// Second level navigation bar
add(new ListView<NavigationMenuItem>("subNav", getSubNav()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<NavigationMenuItem> item) {
NavigationMenuItem navItem = item.getModelObject();
AbstractLink navLink = navItem.link("navLink");
navLink.add(new Label("navLabel", navItem.getLabelModel()));
item.setVisible(navItem.isAccessible());
if (navItem.isActive(MainTemplate.this.getSecondMenuPage())) {
item.add(new ClassAttributeAppender("active"));
}
item.add(navLink);
}
@Override
protected void onConfigure() {
super.onConfigure();
List<NavigationMenuItem> navigationMenuItems = getModelObject();
setVisible(navigationMenuItems != null && !navigationMenuItems.isEmpty());
}
});
// User menu
IModel<String> userDisplayNameModel = new LoadableDetachableModel<String>() {
private static final long serialVersionUID = 1L;
@Override
protected String load() {
String userDisplayName = null;
User user = MavenArtifactNotifierSession.get().getUser();
if (user != null) {
userDisplayName = user.getDisplayName();
}
return userDisplayName;
}
};
WebMarkupContainer userMenuContainer = new WebMarkupContainer("userMenuContainer", userDisplayNameModel) {
private static final long serialVersionUID = 1L;
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(getDefaultModelObject() != null);
}
};
add(userMenuContainer);
Link<Void> viewProfileLink = new BookmarkablePageLink<Void>("viewProfileLink", ViewProfilePage.class);
viewProfileLink.add(new Label("userDisplayName", userDisplayNameModel));
userMenuContainer.add(viewProfileLink);
userMenuContainer.add(new BookmarkablePageLink<Void>("logoutLink", LogoutPage.class));
// Navigation bar right part
// > Sign in
Button signIn = new Button("signIn") {
private static final long serialVersionUID = 1L;
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(!AuthenticatedWebSession.exists() || !AuthenticatedWebSession.get().isSignedIn());
}
};
add(signIn);
IdentificationPopoverPanel identificationPopoverPanel = new IdentificationPopoverPanel("identificationPopoverPanel");
add(identificationPopoverPanel);
BootstrapPopoverOptions popoverOptions = new BootstrapPopoverOptions();
popoverOptions.setTitleText(new ResourceModel("navigation.signIn").getObject());
popoverOptions.setContentComponent(identificationPopoverPanel);
popoverOptions.setPlacement(PopoverPlacement.BOTTOM);
popoverOptions.setHtml(true);
popoverOptions.setContainer(".navbar");
signIn.add(new BootstrapPopoverBehavior(popoverOptions));
signIn.add(new ClassAttributeAppender(Model.of("popover-btn")));
// Footer
add(new FooterPanel("footer"));
// Tooltip