Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.FormatReference


     */
    private void allocateIterations(Menu menu) {
        // Iterate the menu's immediate children and allocate them specific
        // iterated pane instances if they are not explicitly targeted. Start
        // with the initial iteration associated with the menu
        FormatReference allocation = menu.getPane();

        try {
            for (int i = 0; i < menu.getSize(); i++) {
                MenuEntry child = menu.get(i);

                if (child.getPane() == null) {
                    int[] indices;

                    // Store the current iteration for this child then set up
                    // the next iteration
                    getAllocations().put(child, allocation);

                    // Increment the final dimension index ready
                    // for the next allocation
                    allocation =
                            (FormatReference) allocation.clone();

                    indices = allocation.getIndex().getIndicies();

                    indices[indices.length - 1]++;
                }
            }
        } catch (CloneNotSupportedException e) {
View Full Code Here


     * @param entry the entry for which the pane format reference is to be
     *              obtained, may be null
     * @return the pane format reference for the entry, or null
     */
    private FormatReference findTargetPane(MenuEntry entry) {
        FormatReference reference = null;

        if (entry != null) {
            // Prioritize an explicit pane targeting for this entry
            reference = entry.getPane();

View Full Code Here

   
    // Try and find the pane with the specified name, if it could not be
    // found then return and skip the element body.
    String paneName = attributes.getPane ();
    if (paneName != null) {
      FormatReference formatRef = FormatReferenceParser.parsePane(paneName, pageContext);
      Pane pane = pageContext.getPane(formatRef.getStem());
      NDimensionalIndex paneIndex = formatRef.getIndex();
     
      if (pane == null) {
          skipped = true;
          return SKIP_ELEMENT_BODY;
      }
View Full Code Here

        // {layout:get[Format]Instance('stem',index,...)} which evaluates into a
        // FormatReferenceValue. Otherwise, the expression is assumed to result
        // in a string which holds the old style iterated format reference such
        // as 'title.1' or 'title.2.3' in which case the string is treated in
        // the same way as before.
        FormatReference ref = null;
        if (formatRef.startsWith("{") && formatRef.endsWith("}")) {
            stem = formatRef.substring(1, formatRef.length() - 1);
            MarinerRequestContext mrc = pageContext.getRequestContext();
            ExpressionContext ec =
                    MCSExpressionHelper.getExpressionContext(mrc);

            try {
                Expression expr = MCSExpressionHelper.createUnquotedExpression(
                        stem, mrc);

                if (expr != null) {
                    Value value = expr.evaluate(ec);

                    if (value instanceof FormatReferenceValue) {
                        ref = ((FormatReferenceValue)value).
                                asFormatReference();
                    } else {
                        formatRef = value.stringValue().asJavaString();
                    }
                }
            } catch (ExpressionException e) {
                logger.error("unexpected-exception");
            }
        }
       
        // If we have a reference, then the pipeline expression used for the
        // format name was a {layout:get[Format]Instance()} expression. Otherwise we
        // have a 'Normal' format name or a pipeline expression that resulted
        // in a string... in either case we process this as a format name and
        // build a format reference from it.
        if (ref == null) {
            if (namespace != null) {
                if (pageContext.getFormat(formatRef, namespace) != null) {
                    stem = formatRef;
                } else {
                    stem = getFormatReferenceStem(formatRef);
                }
   
                int layoutDim = getFormatDimensions(stem, namespace, pageContext);
           
                // When layoutDim == -1 the formats doesn't exist. When layoutDim == 0
                // it's a regular format. In either case the number of dimensions is 0.
                if (layoutDim <= 0) {
                    ref = new FormatReference(
                            stem,
                            NDimensionalIndex.ZERO_DIMENSIONS);
                } else {
                    NDimensionalIndex tail =
                                createIndex(formatRef, layoutDim);
                    ref = new FormatReference(stem, tail);
                }
            } else {
                ref = new FormatReference(formatRef,
                        NDimensionalIndex.ZERO_DIMENSIONS);
            }
        }
       
        return ref;
View Full Code Here

        StyleValue value = propertyValues.getComputedValue(
                StylePropertyDetails.MCS_CONTAINER);

        StyleFormatReference styleFormatReference =
                (StyleFormatReference) value;
        FormatReference formatReference = styleFormatReference.getReference();
        assertSame(formatReferenceMock, formatReference);
    }
View Full Code Here

        StyleValue value = propertyValues.getComputedValue(
                StylePropertyDetails.MCS_CONTAINER);

        StyleFormatReference styleFormatReference =
                (StyleFormatReference) value;
        FormatReference formatReference = styleFormatReference.getReference();
        assertSame(formatReferenceMock, formatReference);
    }
View Full Code Here

        });

        StylingFunction function = new MCSContainerInstanceFunction();
        StyleFormatReference referenceValue = (StyleFormatReference)
                function.evaluate(evaluationContextMock, "foo", arguments);
        FormatReference reference = referenceValue.getReference();
        assertEquals("Reference", formatReferenceMock, reference);
    }
View Full Code Here

        Value result = expression.evaluate(expressionContext);

        assertTrue("Result not a format reference",
                result instanceof FormatReferenceValue);

        FormatReference ref = ((FormatReferenceValue) result).asFormatReference();
        assertSame(formatReferenceMock, ref);
    }
View Full Code Here

    private PaneInstance getPaneInstance(
            MarinerPageContext pageContext,
            String paneName) {
        PaneInstance paneInstance = null;
        if (paneName != null) {
            FormatReference formatRef = FormatReferenceParser.parsePane(
                    paneName, pageContext);
            Pane pane = pageContext.getPane(formatRef.getStem());
            if (pane != null) {
                paneInstance = (PaneInstance) pageContext.getFormatInstance(
                        pane, formatRef.getIndex());
            }
        }
        return paneInstance;
    }
View Full Code Here

        boolean success = true;

        if (menu != null) {
            MenuEntry currentMenu = menu.getContainer();
            while (currentMenu != null) {
                FormatReference ref = currentMenu.getPane();
                if (ref != null && ref.getStem().equals(pane.getStem())) {
                    // fail the check
                    success = false;
                    logger.warn("menu-target-warning", new Object[]{pane});
                }
                currentMenu = currentMenu.getContainer();
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.FormatReference

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.