return;
}
// Construct a visitor which renders the menu.
// @todo model could use Composite, External and/or Internal Iterator
RendererMenuModelVisitor visitor = new RendererMenuModelVisitor() {
public void rendererVisit(MenuItem item)
throws RendererException {
// Use the menu item renderer which we previously selected
// to render each menu item in a similar fashion.
renderer.render(locator, item);
}
public void rendererVisit(MenuItemGroup group)
throws RendererException {
// For groups of menu items, we ignore the group itself
// and just render the contained menu items.
// Iterate over the children in order.
renderChildren(group);
}
public void rendererVisit(Menu menu) throws RendererException {
// For menus, we render only the root menu.
if (menu.getContainer() == null) {
// process the root menu
MenuBuffer menuBuffer = locator.getMenuBuffer(menu);
DOMOutputBuffer buffer
= (DOMOutputBuffer) menuBuffer.getOutputBuffer();
// Open a paragraph for the select to go in.
// According to openwave style guide this should be nowrap.
// todo: only set whitespace if it was not specified by user
// currently we cannot tell, fix when VBM:2005092701 is fixed
Styles styles = menu.getElementDetails().getStyles();
styles.getPropertyValues().setComputedValue(
StylePropertyDetails.WHITE_SPACE,
WhiteSpaceKeywords.NOWRAP);
Element element = buffer.openStyledElement(
WMLConstants.BLOCH_ELEMENT, styles);
// Open a select for the menu.
element = buffer.openElement("select");
if (menu.getTitle() != null) {
element.setAttribute("title", menu.getTitle());
}
// Iterate over the children in order.
renderChildren(menu);
// Close the select.
buffer.closeElement("select");
// Close the paragraph.
buffer.closeElement(WMLConstants.BLOCH_ELEMENT);
}
// else, ignore nested menus for now
// todo: implement nested menus.
}
};
visitor.accept(menu);
}