Package nextapp.echo2.webrender.output

Examples of nextapp.echo2.webrender.output.CssStyle


    private static final Extent EXTENT_3_PX = new Extent(3, Extent.PX);
    private static final Extent EXTENT_4_PX = new Extent(4, Extent.PX);
    private static final Extent EXTENT_2_PT = new Extent(2, Extent.PT);
   
    public void testRenderUnique() {
        CssStyle cssStyle = new CssStyle();
        InsetsRender.renderToStyle(cssStyle, "padding", new Insets(EXTENT_1_PX, EXTENT_2_PX, EXTENT_3_PX, EXTENT_4_PX));
        assertEquals("2px 3px 4px 1px", cssStyle.getAttribute("padding"));
    }
View Full Code Here


        InsetsRender.renderToStyle(cssStyle, "padding", new Insets(EXTENT_1_PX, EXTENT_2_PX, EXTENT_3_PX, EXTENT_4_PX));
        assertEquals("2px 3px 4px 1px", cssStyle.getAttribute("padding"));
    }

    public void testRenderHV() {
        CssStyle cssStyle = new CssStyle();
        InsetsRender.renderToStyle(cssStyle, "padding", new Insets(EXTENT_2_PX, EXTENT_2_PT));
        assertEquals("2pt 2px 2pt 2px", cssStyle.getAttribute("padding"));
    }
View Full Code Here

        InsetsRender.renderToStyle(cssStyle, "padding", new Insets(EXTENT_2_PX, EXTENT_2_PT));
        assertEquals("2pt 2px 2pt 2px", cssStyle.getAttribute("padding"));
    }

    public void testRenderSame() {
        CssStyle cssStyle = new CssStyle();
        InsetsRender.renderToStyle(cssStyle, "padding", new Insets(EXTENT_2_PT));
        assertEquals("2pt", cssStyle.getAttribute("padding"));
    }
View Full Code Here

*
*/
public class BorderRenderTest extends TestCase {
   
    public void testNull() {
        CssStyle cssStyle = new CssStyle();
        Border border = new Border(null, null, Border.STYLE_NONE);
        BorderRender.renderToStyle(cssStyle, border);
        assertEquals("none", cssStyle.getAttribute("border"));
    }
View Full Code Here

        BorderRender.renderToStyle(cssStyle, border);
        assertEquals("none", cssStyle.getAttribute("border"));
    }
   
    public void testAll() {
        CssStyle cssStyle = new CssStyle();
        Border border = new Border(new Extent(20, Extent.PX), Color.GREEN, Border.STYLE_SOLID);
        BorderRender.renderToStyle(cssStyle, border);
        assertEquals("20px solid #00ff00", cssStyle.getAttribute("border"));
    }
View Full Code Here

public class LayoutDirectionRenderTest extends TestCase {
   
    private static final Locale HEBREW = new Locale("iw");
   
    public void test() {
        CssStyle cssStyle = new CssStyle();
        LayoutDirectionRender.renderToStyle(cssStyle, LayoutDirection.LTR, null);
        assertEquals("ltr", cssStyle.getAttribute("direction"));
        LayoutDirectionRender.renderToStyle(cssStyle, LayoutDirection.RTL, null);
        assertEquals("rtl", cssStyle.getAttribute("direction"));

        LayoutDirectionRender.renderToStyle(cssStyle, LayoutDirection.LTR, Locale.US);
        assertEquals("ltr", cssStyle.getAttribute("direction"));
        LayoutDirectionRender.renderToStyle(cssStyle, LayoutDirection.RTL, HEBREW);
        assertEquals("rtl", cssStyle.getAttribute("direction"));

        LayoutDirectionRender.renderToStyle(cssStyle, LayoutDirection.LTR, Locale.US);
        assertEquals("ltr", cssStyle.getAttribute("direction"));
        LayoutDirectionRender.renderToStyle(cssStyle, LayoutDirection.RTL, HEBREW);
        assertEquals("rtl", cssStyle.getAttribute("direction"));

        LayoutDirectionRender.renderToStyle(cssStyle, null, Locale.US);
        assertEquals("ltr", cssStyle.getAttribute("direction"));
        LayoutDirectionRender.renderToStyle(cssStyle, null, HEBREW);
        assertEquals("rtl", cssStyle.getAttribute("direction"));
    }
View Full Code Here

   
    private class NullComponent extends Component { }
   
    public void testHorizontalWithComponentLTR() {
        Alignment alignment;
        CssStyle cssStyle = new CssStyle();
        Component component = new NullComponent();
        component.setLayoutDirection(LayoutDirection.LTR);
       
        alignment = new Alignment(Alignment.DEFAULT, Alignment.DEFAULT);
        AlignmentRender.renderToStyle(cssStyle, alignment, component);
        assertNull(cssStyle.getAttribute("text-align"));
       
        alignment = new Alignment(Alignment.TOP, Alignment.DEFAULT); // Invalid
        AlignmentRender.renderToStyle(cssStyle, alignment, component);
        assertNull(cssStyle.getAttribute("text-align"));
       
        alignment = new Alignment(Alignment.LEFT, Alignment.DEFAULT);
        AlignmentRender.renderToStyle(cssStyle, alignment, component);
        assertEquals("left", cssStyle.getAttribute("text-align"));
       
        alignment = new Alignment(Alignment.CENTER, Alignment.DEFAULT);
        AlignmentRender.renderToStyle(cssStyle, alignment, component);
        assertEquals("center", cssStyle.getAttribute("text-align"));
       
        alignment = new Alignment(Alignment.RIGHT, Alignment.DEFAULT);
        AlignmentRender.renderToStyle(cssStyle, alignment, component);
        assertEquals("right", cssStyle.getAttribute("text-align"));

        alignment = new Alignment(Alignment.LEADING, Alignment.DEFAULT);
        AlignmentRender.renderToStyle(cssStyle, alignment, component);
        assertEquals("left", cssStyle.getAttribute("text-align"));
       
        alignment = new Alignment(Alignment.TRAILING, Alignment.DEFAULT);
        AlignmentRender.renderToStyle(cssStyle, alignment, component);
        assertEquals("right", cssStyle.getAttribute("text-align"));
    }
View Full Code Here

                + debug + ");");
       
        Element bodyElement = baseDoc.getBodyElement();
       
        // Set body element CSS style.
        CssStyle cssStyle = new CssStyle();
        cssStyle.setAttribute("position", "absolute");
        cssStyle.setAttribute("font-family", "verdana, arial, helvetica, sans-serif");
        cssStyle.setAttribute("font-size", "10pt");
        cssStyle.setAttribute("height", "100%");
        cssStyle.setAttribute("width", "100%");
        cssStyle.setAttribute("padding", "0px");
        cssStyle.setAttribute("margin", "0px");
        cssStyle.setAttribute("overflow", "hidden");
        bodyElement.setAttribute("style", cssStyle.renderInline());
       
        // Render.
        baseDoc.render(conn.getWriter());
    }
View Full Code Here

        int rowCount = gridProcessor.getRowCount();
       
        Element tableElement = document.createElement("table");
        tableElement.setAttribute("id", elementId);

        CssStyle tableCssStyle = new CssStyle();
        tableCssStyle.setAttribute("border-collapse", "collapse");
       
        Insets gridInsets = (Insets) grid.getRenderProperty(Grid.PROPERTY_INSETS);
        String defaultInsetsAttributeValue = gridInsets == null
                ? "0px" : InsetsRender.renderCssAttributeValue(gridInsets);
       
        ColorRender.renderToStyle(tableCssStyle, component);
        FontRender.renderToStyle(tableCssStyle, component);
        BorderRender.renderToStyle(tableCssStyle, border);
        ExtentRender.renderToStyle(tableCssStyle, "height", (Extent) grid.getRenderProperty(Grid.PROPERTY_HEIGHT));
       
        Extent width = (Extent) grid.getRenderProperty(Grid.PROPERTY_WIDTH);
        boolean render100PercentWidthWorkaround = false;
        if (rc.getContainerInstance().getClientProperties().getBoolean(
                ClientProperties.QUIRK_IE_TABLE_PERCENT_WIDTH_SCROLLBAR_ERROR)) {
            if (width != null && width.getUnits() == Extent.PERCENT && width.getValue() == 100) {
                width = null;
                render100PercentWidthWorkaround = true;
            }
        }
        ExtentRender.renderToStyle(tableCssStyle, "width", width);
       
        Extent borderSize = border == null ? null : border.getSize();
        if (borderSize != null) {
            if (!rc.getContainerInstance().getClientProperties().getBoolean(ClientProperties.QUIRK_CSS_BORDER_COLLAPSE_INSIDE)) {
                tableCssStyle.setAttribute("margin", ExtentRender.renderCssAttributeValueHalf(borderSize));
            }
        }
       
        tableElement.setAttribute("style", tableCssStyle.renderInline());
       
        parentNode.appendChild(tableElement);
       
        boolean someColumnsHaveWidths = false;
        for (int i = 0; i < columnCount; ++i) {
            if (gridProcessor.getColumnWidth(i) != null) {
                someColumnsHaveWidths = true;
            }
        }
        if (someColumnsHaveWidths) {
            Element colGroupElement = document.createElement("colgroup");
            tableElement.appendChild(colGroupElement);

            for (int i = 0; i < columnCount; ++i) {
                Element colElement = document.createElement("col");
                Extent columnWidth = gridProcessor.getColumnWidth(i);
                if (columnWidth != null) {
                    colElement.setAttribute("style", "width:" + ExtentRender.renderCssAttributeValue(columnWidth));
                }
                colGroupElement.appendChild(colElement);
            }
        }
       
        Element tbodyElement = document.createElement("tbody");
        tbodyElement.setAttribute("id", elementId + "_tbody");
        tableElement.appendChild(tbodyElement);
       
        Set renderedCells = new HashSet();
       
        for (int rowIndex = 0; rowIndex < rowCount; ++rowIndex) {
            Element trElement = document.createElement("tr");
            trElement.setAttribute("id", elementId + "_tr_" + rowIndex);
            if (gridProcessor.getRowHeight(rowIndex) != null) {
                trElement.setAttribute("style", "height:" + ExtentRender.renderCssAttributeValue(gridProcessor.getRowHeight(rowIndex)));
            }
            tbodyElement.appendChild(trElement);
           
            for (int columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
                Component cell = gridProcessor.getContent(columnIndex, rowIndex);
                if (cell == null) {
                    Element tdElement = document.createElement("td");
                    trElement.appendChild(tdElement);
                    continue;
                }
                if (renderedCells.contains(cell)) {
                    // Cell already rendered.
                    continue;
                }
                renderedCells.add(cell);
               
                Element tdElement = document.createElement("td");
                tdElement.setAttribute("id", elementId + "_td_" + ContainerInstance.getElementId(cell));
                trElement.appendChild(tdElement);

                int columnSpan = gridProcessor.getColumnSpan(columnIndex, rowIndex);
                if (columnSpan > 1) {
                    tdElement.setAttribute("colspan", Integer.toString(columnSpan));
                }
               
                int rowSpan = gridProcessor.getRowSpan(columnIndex, rowIndex);
                if (rowSpan > 1) {
                    tdElement.setAttribute("rowspan", Integer.toString(rowSpan));
                }
           
                CssStyle tdCssStyle = new CssStyle();
                BorderRender.renderToStyle(tdCssStyle, (Border) grid.getRenderProperty(Grid.PROPERTY_BORDER));
                CellLayoutDataRender.renderToElementAndStyle(tdElement, tdCssStyle, cell, getLayoutData(cell),
                        defaultInsetsAttributeValue);
                CellLayoutDataRender.renderBackgroundImageToStyle(tdCssStyle, rc, this, grid, cell);
                tdElement.setAttribute("style", tdCssStyle.renderInline());
               
                if (rowIndex == 0 && render100PercentWidthWorkaround) {
                    // Render string of "sizing dots" in first cell.
                    Element sizingDivElement = document.createElement("div");
                    sizingDivElement.setAttribute("style", "font-size:50px;height:0px;overflow:hidden;");
View Full Code Here

        if (component.getVisibleComponentCount() == 0) {
            // Return if no children (don't even bother to render CSS style)
            return;
        }
       
        CssStyle cssStyle = new CssStyle();
        ColorRender.renderToStyle(cssStyle, component);
        FontRender.renderToStyle(cssStyle, component);
        if (component instanceof Panel) {
            BorderRender.renderToStyle(cssStyle, (Border) component.getRenderProperty(Panel.PROPERTY_BORDER));
            InsetsRender.renderToStyle(cssStyle, "padding", (Insets) component.getRenderProperty(Panel.PROPERTY_INSETS));
        }
       
        if (cssStyle.hasAttributes()) {
            divElement.setAttribute("style", cssStyle.renderInline());
        }

        Component child = component.getVisibleComponent(0);
        ComponentSynchronizePeer syncPeer = SynchronizePeerFactory.getPeerForComponent(child.getClass());
       
View Full Code Here

TOP

Related Classes of nextapp.echo2.webrender.output.CssStyle

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.