Package com.volantis.mcs.protocols.menu.renderer

Examples of com.volantis.mcs.protocols.menu.renderer.RendererMenuModelVisitor


        final SeparatorRenderer separator =
                separatorSelector.selectMenuItemSeparator(menu);
       
        // 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
                   
                    DOMOutputBuffer dom = locator.getOutputBuffer();

                    // Open a menu element so we can see this renderer in the
                    // output.
                    Element menuElement = dom.openElement("menu");

                    // Iterate over the children in order.
                    renderChildren(menu);

                    // Close the menu element.
                    dom.closeElement(menuElement);
                }
                // else, ignore nested menus for now
            }
        };
        visitor.accept(menu);
       
    }
View Full Code Here


            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);

    }
View Full Code Here

        // belonging to this menu.
        menuItemRenderer
                = itemRendererSelector.selectMenuItemRenderer(menu);

        // Get a visitor for rendering the object.
        RendererMenuModelVisitor rendererVisitor = new RendererVisitor();

        // The output buffer for menu markup. This will be null if the
        // menu should not have any markup rendered for it
        OutputBuffer buffer = null;

        // Only render the mender if we have a renderer i.e. one of
        // MCS_MENU_TEXT_STYLE or MCS_MENU_IMAGE_STYLE is not "none".
        if (menuItemRenderer != null) {
            // If the menu is not using pane iteration, then it should be
            // safe to add the menu markup for this menu.

            // NOTE: this means that "scatter" menus which do not add any
            // items into the menu's pane will result in rendundant menu markup
            // being added to the menu pane. This is an obvious candidate for
            // future "optimisation".
            if (!usingPaneIteration) {
                MenuBuffer menuBuffer = bufferLocator.getMenuBuffer(menu);

                // This check is necessary in case the menuBuffer does not
                // exist
                if (menuBuffer != null) {
                    buffer = menuBuffer.getOutputBuffer();

                    menuBracketingRenderer.open(buffer, menu);
                }
            }

            // Render the children of the menu. Note that this avoids visiting the
            // menu being rendered, which means that when a menu is visited in the
            // visitor below, we know it must be a sub-menu. This makes things a
            // little bit clearer.
            rendererVisitor.renderChildren(menu);

            if (buffer != null) {
                // Only close markup that was opened above
                menuBracketingRenderer.close(buffer, menu);
            }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.menu.renderer.RendererMenuModelVisitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.