Examples of TabsContext


Examples of com.volantis.mcs.protocols.widgets.TabsContext

    // javadoc inherited
    public void doRenderOpen(VolantisProtocol protocol, MCSAttributes attributes)
            throws ProtocolException {
        // Create new context for tabs widget
        TabsContext context = pushContext();

        // Save page context necessary for current buffer changes
        // Label and tabs buffers are created
        context.initPageContext(((TabsAttributes) attributes).getPageContext());
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

    // javadoc inherited
    public void renderTabsOpen(VolantisProtocol protocol,
            MCSAttributes attributes) throws ProtocolException {

      TabsContext context = getCurrentContext();
     
        if (!isWidgetSupported(protocol)) {
            // pop labels deviceLayoutContext and tab's contents
            // deviceLayoutContext
            // fallback widget:tab renderer will save output to main buffer
            context.getPageContext().popDeviceLayoutContext();
            context.getPageContext().popDeviceLayoutContext();
            // Don't render anything specific for the tabs element
            return;
        }

        require(MODULE, protocol, attributes);
       
        // Generate an ID, if it's not already there.
        if (attributes.getId() == null) {
            attributes.setId(protocol.getMarinerPageContext()
                    .generateUniqueFCID());
        }

        DOMOutputBuffer mainBuffer = getCurrentBuffer(protocol);

        // Create main table for the tabs
        Styles style = attributes.getStyles();

        style.getPropertyValues().setComputedAndSpecifiedValue(
                StylePropertyDetails.DISPLAY, DisplayKeywords.TABLE);

        Element tabsTableElem = mainBuffer.openStyledElement("table", style);
        tabsTableElem.setAttribute("id", attributes.getId());
        tabsTableElem.setAttribute("border", "0");
        tabsTableElem.setAttribute("cellspacing", "0");
        setElementLocked(protocol, tabsTableElem);

        // set layout on stack for widget:tab's contents
        MarinerPageContext pageContext = context.getPageContext();
        pageContext.pushContainerInstance(getContentsRegionInstance());
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

            // Context is used in fallback mode as well, as extractAltText
            // uses it (i.e. the saved page context) in policy resolving
            return;
        }

        TabsContext context = getCurrentContext();

        // pop labels deviceLayoutContext
        DeviceLayoutContext labelsLayoutToPop = context.getPageContext()
                .getDeviceLayoutContext();
        RegionContent labelsRegionContent = new DeviceLayoutRegionContent(
                labelsLayoutToPop);
        context.getPageContext().popDeviceLayoutContext();

        // pop tab's content RegionInstance
        context.getPageContext().popContainerInstance(getContentsRegionInstance());

        DOMOutputBuffer mainBuffer = getCurrentBuffer(protocol);

        Styles contentsTrStyle = StylingFactory.getDefaultInstance()
          .createInheritedStyles(
            protocol.getMarinerPageContext().getStylingEngine()
            .getStyles(), DisplayKeywords.TABLE_ROW);
               
        // Create tr element for labels in main buffer       
        Element labelsTrElem = mainBuffer.openStyledElement("tr", contentsTrStyle);
       
        labelsTrElem.setAttribute("id", protocol.getMarinerPageContext()
                .generateUniqueFCID());
        // set in order to label occupy only area for content
        labelsTrElem.setAttribute("style", "height: 1px");

        setElementLocked(protocol, labelsTrElem);

        // get main RegionInstance
        ContainerInstance containingInstance = context.getPageContext()
                .getCurrentContainerInstance();

        containingInstance.getCurrentBuffer().transferContentsFrom(
                getLabelsRegionInstance().getCurrentBuffer());
       
        renderTabStripFiller(mainBuffer);
        // Increase colspan for tab strip filler
        context.addColspan(1);

        // Close labels tr
        mainBuffer.closeElement("tr");

        // Create tr element for contents in main buffer               
        Element contentsTrElem = mainBuffer.openStyledElement("tr", contentsTrStyle);
       
        contentsTrElem.setAttribute("id", protocol.getMarinerPageContext()
                .generateUniqueFCID());
        setElementLocked(protocol, contentsTrElem);

        // Create td element with proper style
        Styles contentsTdStyle = StylingFactory.getDefaultInstance()
          .createInheritedStyles(
                 protocol.getMarinerPageContext().getStylingEngine()           
            .getStyles(), DisplayKeywords.TABLE_CELL);
       
        Element contentsTdElem = mainBuffer.openStyledElement("td",
                contentsTdStyle);
        String contentId = protocol.getMarinerPageContext()
                .generateUniqueFCID();
        context.setContentId(contentId);
        contentsTdElem.setAttribute("id", contentId);
        contentsTdElem.setAttribute("colspan", "" + context.getColspan());
        setElementLocked(protocol, contentsTdElem);
        contentsTdElem.getStyles().getPropertyValues()
                .setComputedAndSpecifiedValue(
                        StylePropertyDetails.VERTICAL_ALIGN,
                        VerticalAlignKeywords.TOP);

        // Insert tab contents buffer to main buffer
        // mainBuffer.addOutputBuffer(tabsBuffer);

        // pop tab's contents deviceLayoutContext
        DeviceLayoutContext contentsLayoutToPop = context.getPageContext()
                .getDeviceLayoutContext();
        RegionContent contentsRegionContent = new DeviceLayoutRegionContent(
                contentsLayoutToPop);
        context.getPageContext().popDeviceLayoutContext();

        // add contentsRegionContent to main RegionInstance
        containingInstance.getCurrentBuffer().transferContentsFrom(
                getContentsRegionInstance().getCurrentBuffer());

        // Close contents tr element
        mainBuffer.closeElement("td");
        mainBuffer.closeElement("tr");

        // Close tabs table element in main buffer
        mainBuffer.closeElement("table");

        // Check if any tab was specified as active, if not set
        // the first one as active
        if (null == context.getActiveTabId()) {
            context.setActiveTabId(context.getFirstTabId());
        }

        // Write script
        String[] scriptArrays = generateScripts();
        StringBuffer textToScript = new StringBuffer("Widget.register("
                + createJavaScriptString(attributes.getId()) + ",new Widget.Tabs("
                + createJavaScriptString(attributes.getId()) + ",");
        for (int i = 0; i < scriptArrays.length; i++) {
            textToScript.append("[" + scriptArrays[i] + "],");
        }
        textToScript.append("{activeTabId:"
                + createJavaScriptString(context.getActiveTabId()) + ","
                + "contentId:" + createJavaScriptString(context.getContentId()));

        Styles styleTable = attributes.getStyles();
        StyleValue heightValue = styleTable.getPropertyValues()
                .getSpecifiedValue(StylePropertyDetails.HEIGHT);
        StyleValue positionValue = styleTable.getPropertyValues()
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

                    (TabAttributes) attributes);
            return;
        }

        // Output buffer will be tabs buffer, not main output buffer
        TabsContext context = getCurrentContext();
        DOMOutputBuffer tabsBuffer =
            (DOMOutputBuffer) getContentsRegionInstance().getCurrentBuffer();

        // Generate an ID, if it's not already there.
        if (null == attributes.getId()) {
            attributes.setId(protocol.getMarinerPageContext()
                    .generateUniqueFCID());
        }

        context.registerNewTab().tab = (TabAttributes) attributes;

        // copy border-top style from tab element to border-bottom in label
        // (:mcs-label pseudo class)
        Styles tabXdimeStyles = attributes.getStyles();

        StyleValue borderTopColor = tabXdimeStyles.getPropertyValues()
                .getSpecifiedValue(StylePropertyDetails.BORDER_TOP_COLOR);
        StyleValue borderTopStyle = tabXdimeStyles.getPropertyValues()
                .getSpecifiedValue(StylePropertyDetails.BORDER_TOP_STYLE);
        StyleValue borderTopWidth = tabXdimeStyles.getPropertyValues()
                .getSpecifiedValue(StylePropertyDetails.BORDER_TOP_WIDTH);

        if (borderTopWidth != null) {
            tabXdimeStyles.getNestedStyles(PseudoElements.MCS_LABEL)
                    .getPropertyValues().setComputedAndSpecifiedValue(
                            StylePropertyDetails.BORDER_BOTTOM_COLOR,
                            borderTopColor);
            tabXdimeStyles.getNestedStyles(PseudoElements.MCS_LABEL)
                    .getPropertyValues().setComputedAndSpecifiedValue(
                            StylePropertyDetails.BORDER_BOTTOM_STYLE,
                            borderTopStyle);
            tabXdimeStyles.getNestedStyles(PseudoElements.MCS_LABEL)
                    .getPropertyValues().setComputedAndSpecifiedValue(
                            StylePropertyDetails.BORDER_BOTTOM_WIDTH,
                            borderTopWidth);
        }

        // Prepare styles for tab content; copy, as we remove :mcs-label
        // pseudo element, which is later used
        Styles tabStyles = attributes.getStyles().copy();
               
        if (null != tabStyles) {
            tabStyles.getPropertyValues().setComputedAndSpecifiedValue(
                    StylePropertyDetails.BORDER_TOP_WIDTH,
                    StyleValueFactory.getDefaultInstance().getLength(null, 0,
                            LengthUnit.PX));
           
            tabStyles.removeNestedStyles(PseudoElements.MCS_LABEL);
        }

        // Create div element for tab contents
        Element tabElement = openDivElement(tabStyles, tabsBuffer);       
        tabElement.setAttribute("id", attributes.getId());
        tabElement.setAttribute("style", "display:block;visibility:hidden;position:absolute;z-index:-1;");
        setElementLocked(protocol, tabElement);

        // Check if first tab, if yes then register the id in the context
        if (null == context.getFirstTabId()) {
            context.setFirstTabId(attributes.getId());
        }

        // Check for active tab
        StyleValue initialState = attributes.getStyles().getPropertyValues()
                .getComputedValue(StylePropertyDetails.MCS_INITIAL_STATE);

        if (StyleKeywords.ACTIVE == initialState
                && null == context.getActiveTabId()) {
            context.setActiveTabId(attributes.getId());
        }

        // Process tab label
        int tdsRendered = renderTabLabel((DOMProtocol) protocol,
                (TabAttributes) attributes);
        context.addColspan(tdsRendered);

    }
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

     * @throws ProtocolException
     */
    private void renderFallbackTabOpen(DOMProtocol protocol,
            TabAttributes tabAttributes) throws ProtocolException {

        TabsContext context = getCurrentContext();
        // for fallback tabs buffer is a main buffer
        DOMOutputBuffer tabsBuffer = (DOMOutputBuffer) context.getPageContext()
                .getCurrentOutputBuffer();

        // Get content value specified for ::mcs-label
        Styles tabStyles = tabAttributes.getStyles().copy();
        Styles labelStyles = (null == tabStyles ? null : tabStyles
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

     * @throws ProtocolException
     */
    private void renderFallbackTabClose(DOMProtocol protocol,
            TabAttributes tabAttributes) {

        TabsContext context = getCurrentContext();
        // for fallback tabs buffer is a main buffer
        DOMOutputBuffer tabsBuffer = (DOMOutputBuffer) context.getPageContext()
                .getCurrentOutputBuffer();

        // Close div element opened for tab contents
        tabsBuffer.closeElement("div");

View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

        // We will always render the TD with tab label, and sometimes
        // two extra margins
        int tdsRendered = 1;

        TabsContext context = getCurrentContext();

        context.getPageContext().pushContainerInstance(getLabelsRegionInstance());
        DOMOutputBuffer labelsBuffer =
            (DOMOutputBuffer) getLabelsRegionInstance().getCurrentBuffer();

        Styles tabStyles = attributes.getStyles();
        // Get content value specified for ::mcs-label
               
        Styles inactiveLabelStyles = (null == tabStyles ? null : tabStyles
          .getNestedStyles(PseudoElements.MCS_LABEL));
       
        StyleValue inactiveLabelContent = (null == inactiveLabelStyles ? null
                : inactiveLabelStyles.getPropertyValues().getSpecifiedValue(
                        StylePropertyDetails.CONTENT));

        // Get content value specified for ::mcs-label:active
        Styles activeLabelStyles = (null == inactiveLabelStyles ? null
                : inactiveLabelStyles
                        .getNestedStyles(StatefulPseudoClasses.ACTIVE));
        StyleValue activeLabelContent = (null == activeLabelStyles ? null
                : activeLabelStyles.getPropertyValues().getSpecifiedValue(
                        StylePropertyDetails.CONTENT));

        // If no content was specified for active label,
        // use content from inactive label
        activeLabelContent = (null == activeLabelContent ? inactiveLabelContent
                : activeLabelContent);

        // If no content was specified for ::mcs-label, use default empty string
        if (null == inactiveLabelContent) {
            inactiveLabelContent = STYLE_VALUE_FACTORY.getString(null, "");
            activeLabelContent = inactiveLabelContent;
        } else {
            // Normalize content values - they are provided as a list
            inactiveLabelContent = getSingleStyleValue(inactiveLabelContent);
            activeLabelContent = getSingleStyleValue(activeLabelContent);
        }
        // Check if image labels are used
        context.getCurrentTabAndLabel().usesImageLabels =
          (inactiveLabelContent instanceof StyleComponentURI);

        // Prepare styles for labels
        inactiveLabelStyles.getPropertyValues().setComputedAndSpecifiedValue(
                StylePropertyDetails.WHITE_SPACE, WhiteSpaceKeywords.NOWRAP);
        inactiveLabelStyles.getPropertyValues().setComputedAndSpecifiedValue(
                StylePropertyDetails.DISPLAY, DisplayKeywords.TABLE_CELL);
        // Remove copied styles specified on tab::mcs-label
        inactiveLabelStyles.getPropertyValues().clearPropertyValue(
                StylePropertyDetails.CONTENT);
        inactiveLabelStyles.removeNestedStyles(PseudoElements.MCS_LABEL);
        inactiveLabelStyles.removeNestedStyles(StatefulPseudoClasses.ACTIVE);

        if (null != activeLabelStyles) {
            activeLabelStyles.getPropertyValues()
                    .setComputedAndSpecifiedValue(
                            StylePropertyDetails.WHITE_SPACE,
                            WhiteSpaceKeywords.NOWRAP);
            activeLabelStyles.getPropertyValues().clearPropertyValue(
                    StylePropertyDetails.CONTENT);
            activeLabelStyles.removeNestedStyles(PseudoElements.MCS_LABEL);
            context.getCurrentTabAndLabel().activeLabelStyles = activeLabelStyles;
        }

        // Rendering starts here
        Element tdLeftMargin = null;
        Element tdRightMargin = null;

        // Generate left margin td (if necessary)
        if (!context.getCurrentTabAndLabel().usesImageLabels) {
            tdLeftMargin = renderLabelMarginTds(labelsBuffer,
                    inactiveLabelStyles, StylePropertyDetails.MARGIN_LEFT);
        }
        tdsRendered += (null == tdLeftMargin ? 0 : 1);

        // Create a td with styles specified for tab label
        String labelId = protocol.getMarinerPageContext().generateUniqueFCID();
        Element labelTdElement = labelsBuffer.openStyledElement("td",
                inactiveLabelStyles);
        setElementLocked(protocol, labelTdElement);
        labelTdElement.setAttribute("id", labelId);
        context.getCurrentTabAndLabel().labelTdId = labelId;

        // Open div inside td with no styles
        Styles labelDivStyles = StylingFactory.getDefaultInstance()
                .createStyles(null);
        Element labelDivElement = labelsBuffer.openStyledElement("div",
                labelDivStyles);
        setElementLocked(protocol, labelDivElement);

        // Set div width according to label width
        applyWidthToChild(inactiveLabelStyles.getPropertyValues()
                .getComputedValue(StylePropertyDetails.WIDTH), labelDivElement
                .getStyles());

        // Create styles for anchor
        Styles anchorStyles = StylingFactory.getDefaultInstance().createStyles(
                null);
        anchorStyles.getPropertyValues().setComputedAndSpecifiedValue(
                StylePropertyDetails.MCS_TEXT_UNDERLINE_STYLE,
                MCSTextUnderlineStyleKeywords.NONE);
        anchorStyles.getPropertyValues().setComputedAndSpecifiedValue(
                StylePropertyDetails.COLOR,
                StyleValueFactory.getDefaultInstance().getInherit());
        anchorStyles.getPropertyValues().setComputedAndSpecifiedValue(
                StylePropertyDetails.VERTICAL_ALIGN,
                VerticalAlignKeywords.BOTTOM);

        // Open anchor element with created styles
        Element anchorElement = labelsBuffer.openStyledElement("a",
                anchorStyles);
        anchorElement.setAttribute("href", "javascript:void(null)");
        setElementLocked(protocol, anchorElement);

        String inactiveId = renderLabelContents(protocol, inactiveLabelContent,
                true);

        // Only write second content if it's different than the first one
        String activeId = inactiveId;
        if (inactiveLabelContent != activeLabelContent) {
            activeId = renderLabelContents(protocol, activeLabelContent, false);
        }
        context.getCurrentTabAndLabel().inactiveContentId = inactiveId;
        context.getCurrentTabAndLabel().activeContentId = activeId;

        labelsBuffer.closeElement(anchorElement);
        labelsBuffer.closeElement(labelDivElement);
        labelsBuffer.closeElement(labelTdElement);

        // Generate right margin td (if image labels not used)
        if (!context.getCurrentTabAndLabel().usesImageLabels) {
            tdRightMargin = renderLabelMarginTds(labelsBuffer,
                    inactiveLabelStyles, StylePropertyDetails.MARGIN_RIGHT);
        }
        tdsRendered += (null == tdRightMargin ? 0 : 1);

        // In the end, we remove margin specified on tab label, as it has
        // already been rendered in margin TDs and we don't want the margins
        // rendered in CSS
        if (!context.getCurrentTabAndLabel().usesImageLabels) {
            inactiveLabelStyles.getPropertyValues().clearPropertyValue(
                    StylePropertyDetails.MARGIN_LEFT);
            inactiveLabelStyles.getPropertyValues().clearPropertyValue(
                    StylePropertyDetails.MARGIN_RIGHT);
            if (null != activeLabelStyles) {
                activeLabelStyles.getPropertyValues().clearPropertyValue(
                        StylePropertyDetails.MARGIN_LEFT);
                activeLabelStyles.getPropertyValues().clearPropertyValue(
                        StylePropertyDetails.MARGIN_RIGHT);
            }
        }

        // Also, if image labels are used, set vertical-align:bottom for td
        if (context.getCurrentTabAndLabel().usesImageLabels) {
            labelTdElement.getStyles().getPropertyValues()
                    .setComputedAndSpecifiedValue(
                            StylePropertyDetails.VERTICAL_ALIGN,
                            VerticalAlignKeywords.BOTTOM);
        }

        context.getPageContext().popContainerInstance(getLabelsRegionInstance());

        return tdsRendered;
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

     */
    private String extractAltText(DOMProtocol protocol,
            StyleComponentURI component) throws ProtocolException {

        // Get asset and policy resolvers, resolve component policy
        TabsContext context = getCurrentContext();
        PolicyReferenceResolver referenceResolver = context.getPageContext()
                .getPolicyReferenceResolver();
        AssetResolver assetResolver = context.getPageContext()
                .getAssetResolver();
        RuntimePolicyReference policyReference = referenceResolver
                .resolvePolicyExpression(component.getExpression());

        // Create image asset from the policy and get fallback
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

     * Creates and returns new instance of TabsContext.
     *
     * @return The TabsContext.
     */
    private TabsContext createContext() {
        return new TabsContext();
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.widgets.TabsContext

        StringBuffer[] buffers = new StringBuffer[SCRIPT_ARRAYS_COUNT];
        for (int i = 0; i < buffers.length; i++) {
            buffers[i] = new StringBuffer(30);
        }

        TabsContext context = getCurrentContext();
        List tabAndLabelAttrs = context.getTabAndLabelAttributesList();
        Iterator it = tabAndLabelAttrs.listIterator();

        while (it.hasNext()) {
            TabsContext.TabWithLabelPair entry = (TabsContext.TabWithLabelPair) it
                    .next();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.