private void drawMenu(final Element panel, final MenuItem menuItem) {
if (!isMenuItemAllowed(menuItem)) {
return;
}
if (menuItem.isLeafMenuItem()) {
final LIElement li = Document.get().createLIElement();
final AnchorElement a = Document.get().createAnchorElement();
a.setTitle(menuItem.getTitle());
a.setInnerText(menuItem.getTitle());
a.setHref("#" + application.getPlaceHistoryMapper().getToken(menuItem.getPlace()));
li.appendChild(a);
panel.appendChild(li);
menuItem.setElement(li);
} else {
final LIElement dropdown = Document.get().createLIElement();
dropdown.addClassName("dropdown");
final AnchorElement toogle = Document.get().createAnchorElement();
toogle.setTitle(menuItem.getTitle());
toogle.setInnerText(menuItem.getTitle());
toogle.addClassName("dropdown-toggle");
toogle.setAttribute("data-toggle", "dropdown");// XXX
menuItem.setElement(dropdown);
final UListElement dropdownMenu = Document.get().createULElement();
dropdownMenu.addClassName("dropdown-menu");
dropdown.appendChild(toogle);
dropdown.appendChild(dropdownMenu);
panel.appendChild(dropdown);
for (final MenuItem childItem : menuItem) {
drawMenu(dropdownMenu, childItem);
}
}