Examples of CSSStyle


Examples of nextapp.echo2.webrender.output.CssStyle

        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

Examples of nextapp.echo2.webrender.output.CssStyle

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

Examples of nextapp.echo2.webrender.output.CssStyle

   
    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

Examples of nextapp.echo2.webrender.output.CssStyle

                + 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

Examples of nextapp.echo2.webrender.output.CssStyle

        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

Examples of nextapp.echo2.webrender.output.CssStyle

        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

Examples of nextapp.echo2.webrender.output.CssStyle

     * @param rc the relevant <code>RenderContext</code>
     * @param textComponent the text component
     * @return the style
     */
    protected CssStyle createBaseCssStyle(RenderContext rc, TextComponent textComponent) {
        CssStyle cssStyle = new CssStyle();

        boolean renderEnabled = textComponent.isRenderEnabled();

        Border border;
        Color foreground, background;
        Font font;
        FillImage backgroundImage;
        if (!renderEnabled) {
            // Retrieve disabled style information.
            background = (Color) textComponent.getRenderProperty(TextComponent.PROPERTY_DISABLED_BACKGROUND);
            backgroundImage = (FillImage) textComponent.getRenderProperty(TextComponent.PROPERTY_DISABLED_BACKGROUND_IMAGE);
            border = (Border) textComponent.getRenderProperty(TextComponent.PROPERTY_DISABLED_BORDER);
            font = (Font) textComponent.getRenderProperty(TextComponent.PROPERTY_DISABLED_FONT);
            foreground = (Color) textComponent.getRenderProperty(TextComponent.PROPERTY_DISABLED_FOREGROUND);

            // Fallback to normal styles.
            if (background == null) {
                background = (Color) textComponent.getRenderProperty(TextComponent.PROPERTY_BACKGROUND);
                if (backgroundImage == null) {
                    // Special case:
                    // Disabled background without disabled background image will render disabled background instead of
                    // normal background image.
                    backgroundImage = (FillImage) textComponent.getRenderProperty(TextComponent.PROPERTY_BACKGROUND_IMAGE);
                }
            }
            if (border == null) {
                border = (Border) textComponent.getRenderProperty(TextComponent.PROPERTY_BORDER);
            }
            if (font == null) {
                font = (Font) textComponent.getRenderProperty(TextComponent.PROPERTY_FONT);
            }
            if (foreground == null) {
                foreground = (Color) textComponent.getRenderProperty(TextComponent.PROPERTY_FOREGROUND);
            }
        } else {
            border = (Border) textComponent.getRenderProperty(TextComponent.PROPERTY_BORDER);
            foreground = (Color) textComponent.getRenderProperty(TextComponent.PROPERTY_FOREGROUND);
            background = (Color) textComponent.getRenderProperty(TextComponent.PROPERTY_BACKGROUND);
            font = (Font) textComponent.getRenderProperty(TextComponent.PROPERTY_FONT);
            backgroundImage = (FillImage) textComponent.getRenderProperty(TextComponent.PROPERTY_BACKGROUND_IMAGE);
        }
       
        Alignment alignment = (Alignment) textComponent.getRenderProperty(TextComponent.PROPERTY_ALIGNMENT);
        if (alignment != null) {
            int horizontalAlignment = AlignmentRender.getRenderedHorizontal(alignment, textComponent);
            switch (horizontalAlignment) {
            case Alignment.LEFT:
                cssStyle.setAttribute("text-align", "left");
                break;
            case Alignment.CENTER:
                cssStyle.setAttribute("text-align", "center");
                break;
            case Alignment.RIGHT:
                cssStyle.setAttribute("text-align", "right");
                break;
            }
        }
       
        LayoutDirectionRender.renderToStyle(cssStyle, textComponent.getLayoutDirection(), textComponent.getLocale());
        BorderRender.renderToStyle(cssStyle, border);
        ColorRender.renderToStyle(cssStyle, foreground, background);
        FontRender.renderToStyle(cssStyle, font);
        FillImageRender.renderToStyle(cssStyle, rc, this, textComponent, IMAGE_ID_BACKGROUND, backgroundImage,
                FillImageRender.FLAG_DISABLE_FIXED_MODE);
       
        InsetsRender.renderToStyle(cssStyle, "padding", (Insets) textComponent.getRenderProperty(TextComponent.PROPERTY_INSETS));
       
        Extent width = (Extent) textComponent.getRenderProperty(TextComponent.PROPERTY_WIDTH);
        Extent height = (Extent) textComponent.getRenderProperty(TextComponent.PROPERTY_HEIGHT);

        if (width != null) {
            cssStyle.setAttribute("width", ExtentRender.renderCssAttributeValue(width));
        }

        if (height != null) {
            cssStyle.setAttribute("height", ExtentRender.renderCssAttributeValue(height));
        }
        return cssStyle;
    }
View Full Code Here

Examples of nextapp.echo2.webrender.output.CssStyle

        Table table = (Table) component;
        Border border = (Border) table.getRenderProperty(Table.PROPERTY_BORDER);
        Insets tableInsets = (Insets) table.getRenderProperty(Table.PROPERTY_INSETS);
        String defaultInsetsAttributeValue = tableInsets == null
                ? "0px" : InsetsRender.renderCssAttributeValue(tableInsets);
        CssStyle styleCss = new CssStyle();
        styleCss.setAttribute("padding", defaultInsetsAttributeValue);
        BorderRender.renderToStyle(styleCss, border);
        DomUpdate.renderStyleSheetAddRule(rc.getServerMessage(), "TD.c-" + component.getRenderId(), styleCss.renderInline());
       
        Element domAddTableElement = DomUpdate.renderElementAdd(rc.getServerMessage());
        DocumentFragment htmlFragment = rc.getServerMessage().getDocument().createDocumentFragment();
        renderHtml(rc, update, htmlFragment, component);
        DomUpdate.renderElementAddContent(rc.getServerMessage(), domAddTableElement, targetId, htmlFragment);
View Full Code Here

Examples of nextapp.echo2.webrender.output.CssStyle

       
        Document document = parentNode.getOwnerDocument();
        Element tableElement = document.createElement("table");
        tableElement.setAttribute("id", elementId);

        CssStyle tableCssStyle = new CssStyle();
        tableCssStyle.setAttribute("border-collapse", "collapse");
       
        if (((Boolean) table.getRenderProperty(Table.PROPERTY_SELECTION_ENABLED, Boolean.FALSE)).booleanValue()) {
            tableCssStyle.setAttribute("cursor", "pointer");
        }
       
        Insets tableInsets = (Insets) table.getRenderProperty(Table.PROPERTY_INSETS);
       
        String defaultInsetsAttributeValue = tableInsets == null ? "0px" : InsetsRender.renderCssAttributeValue(tableInsets);
       
        ColorRender.renderToStyle(tableCssStyle, component);
        FontRender.renderToStyle(tableCssStyle, component);
        BorderRender.renderToStyle(tableCssStyle, border);
        if (borderSize != null) {
            if (!rc.getContainerInstance().getClientProperties().getBoolean(
                    ClientProperties.QUIRK_CSS_BORDER_COLLAPSE_INSIDE)) {
                tableCssStyle.setAttribute("margin", ExtentRender.renderCssAttributeValueHalf(borderSize));
            }
        }
       
        Extent width = (Extent) table.getRenderProperty(Table.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);
       
        tableElement.setAttribute("style", tableCssStyle.renderInline());
       
        parentNode.appendChild(tableElement);
       
        TableColumnModel columnModel = table.getColumnModel();
        int columnCount = columnModel.getColumnCount();
View Full Code Here

Examples of nextapp.echo2.webrender.output.CssStyle

        boolean selectionEnabled = ((Boolean) table.getRenderProperty(Table.PROPERTY_SELECTION_ENABLED,
                Boolean.FALSE)).booleanValue();
       
        String rolloverStyle = "";
        if (rolloverEnabled) {
            CssStyle rolloverCssStyle = new CssStyle();
            ColorRender.renderToStyle(rolloverCssStyle,
                    (Color) table.getRenderProperty(Table.PROPERTY_ROLLOVER_FOREGROUND),
                    (Color) table.getRenderProperty(Table.PROPERTY_ROLLOVER_BACKGROUND));
            FontRender.renderToStyle(rolloverCssStyle,
                    (Font) table.getRenderProperty(Table.PROPERTY_ROLLOVER_FONT));
            FillImageRender.renderToStyle(rolloverCssStyle, rc, this, table, IMAGE_ID_ROLLOVER_BACKGROUND,
                    (FillImage) table.getRenderProperty(Table.PROPERTY_ROLLOVER_BACKGROUND_IMAGE),
                    FillImageRender.FLAG_DISABLE_FIXED_MODE);
            if (rolloverCssStyle.hasAttributes()) {
                rolloverStyle = rolloverCssStyle.renderInline();
            }
        }
       
        String selectionStyle = "";
        if (selectionEnabled) {
            CssStyle selectionCssStyle = new CssStyle();
            ColorRender.renderToStyle(selectionCssStyle,
                    (Color) table.getRenderProperty(Table.PROPERTY_SELECTION_FOREGROUND),
                    (Color) table.getRenderProperty(Table.PROPERTY_SELECTION_BACKGROUND));
            FontRender.renderToStyle(selectionCssStyle,
                    (Font) table.getRenderProperty(Table.PROPERTY_SELECTION_FONT));
            FillImageRender.renderToStyle(selectionCssStyle, rc, this, table, IMAGE_ID_SELECTION_BACKGROUND,
                    (FillImage) table.getRenderProperty(Table.PROPERTY_SELECTION_BACKGROUND_IMAGE),
                    FillImageRender.FLAG_DISABLE_FIXED_MODE);
            if (selectionCssStyle.hasAttributes()) {
                selectionStyle = selectionCssStyle.renderInline();
            }
        }
       
        Element itemizedUpdateElement = serverMessage.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE,
                "EchoTable.MessageProcessor", "init",  TABLE_INIT_KEYS,
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.