showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
showMenu.addStyleName("valo-menu-toggle");
showMenu.setIcon(FontAwesome.LIST);
menu.addComponent(showMenu);
Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>",
ContentMode.HTML);
title.setSizeUndefined();
top.addComponent(title);
top.setExpandRatio(title, 1);
MenuBar settings = new MenuBar();
settings.addStyleName("user-menu");
StringGenerator sg = new StringGenerator();
MenuItem settingsItem = settings.addItem(
sg.nextString(true) + " " + sg.nextString(true)
+ sg.nextString(false), new ThemeResource(
"../tests-valo/img/profile-pic-300px.jpg"), null);
settingsItem.addItem("Edit Profile", null);
settingsItem.addItem("Preferences", null);
settingsItem.addSeparator();
settingsItem.addItem("Sign Out", null);
menu.addComponent(settings);
menuItemsLayout.setPrimaryStyleName("valo-menuitems");
menu.addComponent(menuItemsLayout);
Label label = null;
int count = -1;
for (final Entry<String, String> item : menuItems.entrySet()) {
if (item.getKey().equals("labels")) {
label = new Label("Components", ContentMode.HTML);
label.setPrimaryStyleName("valo-menu-subtitle");
label.addStyleName("h4");
label.setSizeUndefined();
menuItemsLayout.addComponent(label);
}
if (item.getKey().equals("panels")) {
label.setValue(label.getValue()
+ " <span class=\"valo-menu-badge\">" + count
+ "</span>");
count = 0;
label = new Label("Containers", ContentMode.HTML);
label.setPrimaryStyleName("valo-menu-subtitle");
label.addStyleName("h4");
label.setSizeUndefined();
menuItemsLayout.addComponent(label);
}
if (item.getKey().equals("calendar")) {
label.setValue(label.getValue()
+ " <span class=\"valo-menu-badge\">" + count
+ "</span>");
count = 0;
label = new Label("Other", ContentMode.HTML);
label.setPrimaryStyleName("valo-menu-subtitle");
label.addStyleName("h4");
label.setSizeUndefined();
menuItemsLayout.addComponent(label);
}
Button b = new Button(item.getValue(), new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
navigator.navigateTo(item.getKey());
}
});
if (count == 2) {
b.setCaption(b.getCaption()
+ " <span class=\"valo-menu-badge\">123</span>");
}
b.setHtmlContentAllowed(true);
b.setPrimaryStyleName("valo-menu-item");
b.setIcon(testIcon.get());
menuItemsLayout.addComponent(b);
count++;
}
label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">"
+ count + "</span>");
return menu;
}