} else {
add(new Label("username", user.getDisplayName()));
}
List<MenuItem> standardItems = new ArrayList<MenuItem>();
standardItems.add(new MenuDivider());
if (user.canAdmin() || user.canCreate()) {
standardItems.add(new PageLinkMenuItem("gb.newRepository", app().getNewRepositoryPage()));
}
standardItems.add(new PageLinkMenuItem("gb.myProfile", UserPage.class,
WicketUtils.newUsernameParameter(user.username)));
if (editCredentials) {
standardItems.add(new PageLinkMenuItem("gb.changePassword", ChangePasswordPage.class));
}
standardItems.add(new MenuDivider());
add(newSubmenu("standardMenu", user.getDisplayName(), standardItems));
if (showAdmin) {
// admin menu
List<MenuItem> adminItems = new ArrayList<MenuItem>();
adminItems.add(new MenuDivider());
adminItems.add(new PageLinkMenuItem("gb.users", UsersPage.class));
adminItems.add(new PageLinkMenuItem("gb.teams", TeamsPage.class));
boolean showRegistrations = app().federation().canFederate()
&& app().settings().getBoolean(Keys.web.showFederationRegistrations, false);
if (showRegistrations) {
adminItems.add(new PageLinkMenuItem("gb.federation", FederationPage.class));
}
adminItems.add(new MenuDivider());
add(newSubmenu("adminMenu", getString("gb.administration"), adminItems));
} else {
add(new Label("adminMenu").setVisible(false));
}
// plugin extension items
List<MenuItem> extensionItems = new ArrayList<MenuItem>();
List<UserMenuExtension> extensions = app().plugins().getExtensions(UserMenuExtension.class);
for (UserMenuExtension ext : extensions) {
List<MenuItem> items = ext.getMenuItems(user);
extensionItems.addAll(items);
}
if (extensionItems.isEmpty()) {
// no extension items
add(new Label("extensionsMenu").setVisible(false));
} else {
// found extension items
extensionItems.add(0, new MenuDivider());
add(newSubmenu("extensionsMenu", getString("gb.extensions"), extensionItems));
extensionItems.add(new MenuDivider());
}
add(new BookmarkablePageLink<Void>("logout",
LogoutPage.class).setVisible(standardLogin));
}