Package nextapp.echo2.app

Examples of nextapp.echo2.app.Grid


     * |__|__|
     * |9 |XX|
     * |__|XX|
     */
    public void testSimpleWithOversidedColumnSpan() {
        Grid grid = new Grid();
        for (int i = 0; i < 10; ++i) {
            Label label = new Label();
            if (i == 4) {
                GridLayoutData layoutData = new GridLayoutData();
                layoutData.setColumnSpan(3);
                label.setLayoutData(layoutData);
            }
            grid.add(label);
        }
       
        GridProcessor gridProcessor = new GridProcessor(grid);
       
        // Verify Grid size is correct.
View Full Code Here


     * |__|  |
     * |3 |  |
     * |__|__|
     */
    public void testStaggeredSpans() {
        Grid grid = new Grid();
        for (int i = 0; i < 4; ++i) {
            Label label = new Label();
            if (i % 2 == 0) {
                GridLayoutData gridLayoutData = new GridLayoutData();
                gridLayoutData.setRowSpan(2);
                label.setLayoutData(gridLayoutData);
            }
            grid.add(label);
        }
       
        GridProcessor gridProcessor = new GridProcessor(grid);
       
        // Verify Grid size is correct.
View Full Code Here

   
    /**
     * Test retrieving column widths and row heights.
     */
    public void testBasicColumnWidthAndRowHeight() {
        Grid grid = new Grid(3);
        for (int i = 0; i < 12; ++i) {
            grid.add(new Label());
        }
        for (int i = 0; i < 4; ++i) {
            grid.setColumnWidth(i, new Extent(i + 1));
            grid.setRowHeight(i, new Extent((i + 1)* 10));
        }
       
        GridProcessor gridProcessor = new GridProcessor(grid);
        assertEquals(3, gridProcessor.getColumnCount());
        assertEquals(4, gridProcessor.getRowCount());
        assertEquals(new Extent(1), gridProcessor.getColumnWidth(0));
        assertEquals(new Extent(2), gridProcessor.getColumnWidth(1));
        assertEquals(new Extent(3), gridProcessor.getColumnWidth(2));
        assertEquals(new Extent(10), gridProcessor.getRowHeight(0));
        assertEquals(new Extent(20), gridProcessor.getRowHeight(1));
        assertEquals(new Extent(30), gridProcessor.getRowHeight(2));
        assertEquals(new Extent(40), gridProcessor.getRowHeight(3));
       
        grid.setOrientation(Grid.ORIENTATION_VERTICAL);
        gridProcessor = new GridProcessor(grid);
        assertEquals(4, gridProcessor.getColumnCount());
        assertEquals(3, gridProcessor.getRowCount());
        assertEquals(new Extent(1), gridProcessor.getColumnWidth(0));
        assertEquals(new Extent(2), gridProcessor.getColumnWidth(1));
View Full Code Here

   
    /**
     * Test a grid with no child components.
     */
    public void testEmptyGrid() {
        Grid grid = new Grid();
        GridProcessor gridProcessor = new GridProcessor(grid);
        assertEquals(0, gridProcessor.getColumnCount());
        assertEquals(0, gridProcessor.getRowCount());
    }
View Full Code Here

     * |  |XX|XX|XX|
     * |__|XX|XX|XX|
     */
   
    public void testLessThanSize() {
        Grid grid = new Grid();
        grid.setSize(4);
       
        grid.add(new Label());
       
        GridProcessor gridProcessor = new GridProcessor(grid);
        assertEquals(1, gridProcessor.getColumnCount());
        assertEquals(1, gridProcessor.getRowCount());
    }
View Full Code Here

     * |  |XX|XX|XX|
     * |__|XX|XX|XX|
     */
   
    public void testLessThanSizeWithRowSpan() {
        Grid grid = new Grid();
        grid.setSize(4);
       
        Label label = new Label();
        GridLayoutData gridLayoutData = new GridLayoutData();
        gridLayoutData.setRowSpan(3);
        label.setLayoutData(gridLayoutData);
        grid.add(label);
       
        GridProcessor gridProcessor = new GridProcessor(grid);
        assertEquals(1, gridProcessor.getColumnCount());
        assertEquals(1, gridProcessor.getRowCount());
    }
View Full Code Here

     * |2 |  |3 |   |3 |  |  |
     * |__|__|__|   |__|__|__|
     */
    public void testInvalidAttemptCollision() {
        GridLayoutData layoutData;
        Grid grid = new Grid(3);
        grid.add(new Label("0"));
        Label verticalCollider = new Label("VC");
        layoutData = new GridLayoutData();
        layoutData.setRowSpan(3);
        verticalCollider.setLayoutData(layoutData);
        grid.add(verticalCollider);
        grid.add(new Label("1"));
        Label horizontalCollider = new Label("HC");
        layoutData = new GridLayoutData();
        layoutData.setColumnSpan(3);
        horizontalCollider.setLayoutData(layoutData);
        grid.add(horizontalCollider);
        grid.add(new Label("2"));
        grid.add(new Label("3"));
        GridProcessor gridProcessor = new GridProcessor(grid);
        assertEquals("0", ((Label) gridProcessor.getContent(0, 0)).getText());
        assertEquals("VC", ((Label) gridProcessor.getContent(1, 0)).getText());
        assertEquals("1", ((Label) gridProcessor.getContent(2, 0)).getText());
        assertEquals("HC", ((Label) gridProcessor.getContent(0, 1)).getText());
View Full Code Here

     * |XX|  |
     * |XX|  |    3
     * |XX|__|
     */
    public void testOutOfBoundsRowSpan() {
        Grid grid = new Grid();
        grid.add(new Label());

        Label label = new Label();
        GridLayoutData layoutData = new GridLayoutData();
        layoutData.setRowSpan(4);
        label.setLayoutData(layoutData);
        grid.add(label);
       
        GridProcessor gridProcessor =  new GridProcessor(grid);

        // Verify Grid size is correct.
        assertEquals(2, gridProcessor.getColumnCount());
View Full Code Here

     * @see nextapp.echo2.webcontainer.DomUpdateSupport#renderHtml(nextapp.echo2.webcontainer.RenderContext,
     *      nextapp.echo2.app.update.ServerComponentUpdate, org.w3c.dom.Node, nextapp.echo2.app.Component)
     */
    public void renderHtml(RenderContext rc, ServerComponentUpdate update, Node parentNode, Component component) {
        Document document = parentNode.getOwnerDocument();
        Grid grid = (Grid) component;
        Border border = (Border) grid.getRenderProperty(Grid.PROPERTY_BORDER);
        String elementId = ContainerInstance.getElementId(grid);
        GridProcessor gridProcessor = new GridProcessor(grid);
        int columnCount = gridProcessor.getColumnCount();
        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());
               
View Full Code Here

        SplitPaneLayoutData splitPaneLayoutData = new SplitPaneLayoutData();
        splitPaneLayoutData.setInsets(new Insets(10));
        setLayoutData(splitPaneLayoutData);
        setCellSpacing(new Extent(20));
       
        Grid grid = new Grid(2);
        grid.setBorder(new Border(2, Color.BLUE, Border.STYLE_GROOVE));
        grid.setInsets(new Insets(10, 5));
        add(grid);
       
        Label label;
       
        label = new Label("Server Error URI:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        serverErrorUriText = new TextField();
        serverErrorUriText.setStyleName("Default");
        grid.add(serverErrorUriText);
       
        label = new Label("Server Error Message:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        serverErrorMessageText = new TextField();
        serverErrorMessageText.setStyleName("Default");
        grid.add(serverErrorMessageText);
       
        label = new Label("Session Expiration URI:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        sessionExpirationUriText = new TextField();
        sessionExpirationUriText.setStyleName("Default");
        grid.add(sessionExpirationUriText);
       
        label = new Label("Session Expiration Message:");
        label.setStyle(PROMPT_STYLE);
        grid.add(label);
       
        sessionExpirationMessageText = new TextField();
        sessionExpirationMessageText.setStyleName("Default");
        grid.add(sessionExpirationMessageText);
       
        Button updateButton = new Button("Update ClientConfiguration");
        updateButton.setStyleName("Default");
        updateButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
View Full Code Here

TOP

Related Classes of nextapp.echo2.app.Grid

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.