use of de.agilecoders.wicket.core.markup.html.bootstrap.navbar.Navbar in project hale by halestudio.
the class BasePage method addControls.
/**
* Add page controls
*
* @param loggedIn if a user is logged in
*/
protected void addControls(boolean loggedIn) {
add(new HtmlTag("html"));
add(new OptimizedMobileViewportMetaTag("viewport"));
add(new ChromeFrameMetaTag("chrome-frame"));
// enable theme switching
add(new BootstrapBaseBehavior());
// set link to home page
WebApplication app = (WebApplication) this.getApplication();
// set application title & determine if login page is enabled
String applicationTitle = BaseWebApplication.DEFAULT_TITLE;
boolean loginEnabled = false;
if (app instanceof BaseWebApplication) {
BaseWebApplication bwa = (BaseWebApplication) app;
applicationTitle = bwa.getMainTitle();
loginEnabled = bwa.getLoginPageClass() != null;
}
String pageTitle = applicationTitle.replace("-", "»");
// Label applicatonTitleLabel = new Label("base-application-title", applicationTitle);
// applicatonTitleLabel.setEscapeModelStrings(false);
// add(applicatonTitleLabel);
// get specific page title
PageDescription anno = getClass().getAnnotation(PageDescription.class);
if (anno != null && anno.title() != null) {
pageTitle = pageTitle + " » " + anno.title();
}
Label pageTitleLabel = new Label("base-page-title", pageTitle);
pageTitleLabel.setEscapeModelStrings(false);
add(pageTitleLabel);
// create navigation bar
this.navbar = new Navbar("navbar");
add(navbar);
navbar.setPosition(Position.TOP);
// navbar.setBrandImage(new PackageResourceReference(BasePage.class, "graphics/logo.png"),
// Model.<String> of());
navbar.brandName(Model.of(applicationTitle));
navbar.setInverted(true);
if (loginEnabled) {
if (!loggedIn) {
// login link
NavbarButton<Void> loginButton = new NavbarButton<>(((BaseWebApplication) app).getLoginPageClass(), Model.of("Login"));
navbar.addComponents(NavbarComponents.transform(ComponentPosition.RIGHT, loginButton));
} else {
// logout link
String logoutUrl = ((WebApplication) getApplication()).getServletContext().getContextPath() + "/j_spring_security_logout";
NavbarExternalLink logoutLink = new NavbarExternalLink(logoutUrl, "Logout");
logoutLink.setIconType(IconType.off);
logoutLink.setInverted(true);
// user settings
NavbarButton<Void> userButton = new NavbarButton<Void>(UserSettingsPage.class, Model.of(UserUtil.getUserName(null)));
if (UserUtil.isAdmin()) {
userButton.setIconType(IconType.star);
} else {
userButton.setIconType(IconType.user);
}
/*
* XXX instead of getting the user name each time from DB, store
* it somewhere?
*/
navbar.addComponents(NavbarComponents.transform(ComponentPosition.RIGHT, userButton, logoutLink));
}
}
// breadcrumbs
if (Boolean.parseBoolean(System.getProperty("hale.webapp.breadcrumbs", "false"))) {
add(new SimpleBreadcrumbPanel("breadcrumb", this.getClass(), "Home", "/"));
} else {
add(new WebMarkupContainer("breadcrumb"));
}
// about
add(new BookmarkablePageLink<>("about", AboutPage.class));
// contact
add(new BookmarkablePageLink<>("contact", ContactPage.class));
if (app instanceof BaseWebApplication) {
BaseWebApplication bwa = (BaseWebApplication) app;
bwa.addNavBarExtras(navbar, loggedIn);
}
}
use of de.agilecoders.wicket.core.markup.html.bootstrap.navbar.Navbar in project ocvn by devgateway.
the class BasePage method newNavbar.
/**
* creates a new {@link Navbar} instance
*
* @param markupId
* The components markup id.
* @return a new {@link Navbar} instance
*/
protected Navbar newNavbar(final String markupId) {
Navbar navbar = new Navbar(markupId);
/**
* Make sure to update the BaseStyles when the navbar position changes.
*
* @see org.devgateway.toolkit.forms.wicket.styles.BaseStyles
*/
navbar.setPosition(Navbar.Position.TOP);
navbar.setInverted(true);
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, newHomeMenu(), newMyDashboardsMenu(), newAdminMenu(), newAccountMenu(), newLogoutMenu()));
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.LEFT, newLanguageMenu()));
return navbar;
}
use of de.agilecoders.wicket.core.markup.html.bootstrap.navbar.Navbar in project oc-explorer by devgateway.
the class BasePage method newNavbar.
/**
* creates a new {@link Navbar} instance
*
* @param markupId
* The components markup id.
* @return a new {@link Navbar} instance
*/
protected Navbar newNavbar(final String markupId) {
Navbar navbar = new Navbar(markupId);
/**
* Make sure to update the BaseStyles when the navbar position changes.
* @see org.devgateway.toolkit.forms.wicket.styles.BaseStyles
*/
navbar.setPosition(Navbar.Position.TOP);
navbar.setInverted(true);
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, newHomeMenu(), newMyDashboardsMenu(), newAdminMenu(), newAccountMenu(), newLogoutMenu()));
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.LEFT, newLanguageMenu()));
return navbar;
}
Aggregations