Package com.volantis.mcs.papi

Examples of com.volantis.mcs.papi.MenuItemAttributes


     * required values.
     *
     * @return populated MenuItemAttributes.
     */
    private MenuItemAttributes createAttributes() {
        MenuItemAttributes menuItemAttrs = new MenuItemAttributes();

        menuItemAttrs.setShortcut(shortcut);
        menuItemAttrs.setHref(href);
        menuItemAttrs.setPrompt(prompt);
        menuItemAttrs.setOffColor(offcolor);
        menuItemAttrs.setOffImage(offimage);
        menuItemAttrs.setOnColor(oncolor);
        menuItemAttrs.setOnImage(onimage);
        menuItemAttrs.setRolloverImage(rolloverimage);
        menuItemAttrs.setSegment(segment);
        menuItemAttrs.setTarget(target);
        menuItemAttrs.setText(text);
        menuItemAttrs.setTitle(title);
        menuItemAttrs.setStyleClass(styleClass);
        menuItemAttrs.setId(id);

        return menuItemAttrs;
    }
View Full Code Here


        pageContext.setPolicyReferenceResolver(
                PolicyReferenceResolverTestHelper.getCommonExpectations(
                        expectations, mockFactory));

        MenuItemAttributes menuItemAttrs = createAttributes();

        assertEquals("Set title should not have been called",
                null,
                menuModelBuilder.getTitle());
        int result = element.elementStart(requestContext, menuItemAttrs);
View Full Code Here

        MenuModelBuilder menuModelBuilder = pageContext.getMenuBuilder();
        //builder#startMenuItem will fail unless this has been called
        menuModelBuilder.startMenu();

        MenuItemAttributes menuItemAttrs = createAttributes();
        int result = element.elementStart(requestContext, menuItemAttrs);

        assertTrue("Unexpected value returned from MenuItemElement.  Should " +
                "have been PROCESS_ELEMENT_BODY.",
                result == PAPIElement.PROCESS_ELEMENT_BODY);
View Full Code Here

     */
    private void buildAndTestItem(MenuItemElementImpl element, String name,
                                  MarinerRequestContext requestContext)
                                                            throws Exception {
        int result;
        MenuItemAttributes menuItemAttributes = new MenuItemAttributes();

        // Create attributes
        menuItemAttributes = createBasicAttributes(menuItemAttributes, name);

        // Start element
View Full Code Here

            throws PAPIException {

        MarinerPageContext pageContext =
                ContextInternals.getMarinerPageContext(context);

        MenuItemAttributes attributes = (MenuItemAttributes) papiAttributes;

        Styles styles = pageContext.getStylingEngine().getStyles();

        processMenuItemStyles(attributes, styles);

        MenuModelBuilder builder = pageContext.getMenuBuilder();

        try {
            // Start a new menu item
            builder.startMenuItem();

            // Start a new menu label
            builder.startLabel();

            // Start a new menu text
            builder.startText();

            // Set the text by constructing an artificial output buffer from
            // the text attribute
            // NB: The allocation mechanism must be compatible with the
            //     de-allocation mechanism used in
            //     {@link MenuElement#releaseLabelOutputBuffers}
            OutputBuffer text = pageContext.getProtocol().
                    getOutputBufferFactory().createOutputBuffer();
            text.writeText(attributes.getText());
            builder.setText(text);

            // End the menu text
            builder.endText();

            // OK, get the attributes from PAPI
            String onImage = attributes.getOnImage();
            String offImage = attributes.getOffImage();
            String rolloverImage = attributes.getRolloverImage();
            String image = attributes.getImage();

            // Set the normal (on) and over (off) images
            setNormalAndOverImages(pageContext, onImage, offImage,
                    rolloverImage, image);

            // Create the menu icon on the builder
            if (normal != null) {
                // Start a new menu icon
                builder.startIcon();

                // Set the values
                builder.setNormalImageURL(normal);
                if (over != null) {
                    builder.setOverImageURL(over);
                }

                // End the menu icon
                builder.endIcon();
            }

            // End the menu label;
            builder.endLabel();

            // Set the stylistic information in the model for this element.
            MenuInternals.setElementDetails(builder, attributes,
                    styles);

            // Set the segment
            builder.setSegment(attributes.getSegment());

            // Set the target
            builder.setTarget(attributes.getTarget());

            // Set the event handling
            MenuInternals.setEvents(builder, attributes, pageContext);

            // Set the pane attribute
            MenuInternals.setPane(builder, attributes.getPane(), pageContext);

            // Initialise the attributes specific to this field.
            String accessKey = attributes.getAccessKey();
            String shortcut = attributes.getShortcut();

            if (shortcut != null) {
                if (accessKey != null) {
                    throw new PAPIException(exceptionLocalizer.
                            format(
                            "menu-building-shortcut-and-accesskey-error"));
                }
            } else {
                shortcut = accessKey;
            }

            PolicyReferenceResolver resolver =
                    pageContext.getPolicyReferenceResolver();

            // Process the shortcut
            TextAssetReference shortcutObj =
                    resolver.resolveQuotedTextExpression(shortcut);
            builder.setShortcut(shortcutObj);

            //Process the href as a mariner expression
            LinkAssetReference href = resolver.resolveQuotedLinkExpression(
                    attributes.getHref(), PageURLType.MENU_ITEM);
            builder.setHref(href);

            // Process the prompt as a mariner expression
            TextAssetReference prompt = resolver.resolveQuotedTextExpression(
                    attributes.getPrompt());
            builder.setPrompt(prompt);

            // Set the title.
            builder.setTitle(attributes.getTitle());

        } catch (BuilderException be) {
            logger.error("menu-building-error", be);
            throw new PAPIException(
                    exceptionLocalizer.format("menu-building-error"), be);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.papi.MenuItemAttributes

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.