MenuItem defaultMenuItem = null;
int length = slideNavigation.getItems().length();
for (int i=0; i<length; i++)
{
SlideNavigationItem item = slideNavigation.getItems().get(i);
String title = item.getTitle();
if (StringUtil.isNullOrEmpty(title))
title = "(Untitled Slide)";
StringBuilder indentBuilder = new StringBuilder();
for (int level=0; level<item.getIndent(); level++)
indentBuilder.append(" ");
SafeHtmlBuilder labelBuilder = new SafeHtmlBuilder();
labelBuilder.appendHtmlConstant(indentBuilder.toString());
labelBuilder.appendEscaped(title);
final int targetSlide = i;
final MenuItem menuItem = new MenuItem(
labelBuilder.toSafeHtml(),
new Command()
{
public void execute()
{
navigateToSlide(editor, targetSlide);
}
});
menu.addItem(menuItem);
// see if this is the default menu item
if (defaultMenuItem == null &&
item.getLine() >= (docDisplay_.getSelectionStart().getRow()))
{
defaultMenuItem = menuItem;
}
}