Package com.vaadin.tests.components.table

Source Code of com.vaadin.tests.components.table.CellStyleGeneratorTest

package com.vaadin.tests.components.table;

import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.TestUtils;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.CellStyleGenerator;

@SuppressWarnings("serial")
public class CellStyleGeneratorTest extends TestBase {

    @Override
    protected void setup() {
        TestUtils
                .injectCSS(getMainWindow(),
                        ".v-table-cell-content-red{background:red;}.v-table-row-blue{background:blue;}");

        CellStyleGenerator g = new CellStyleGenerator() {

            @Override
            public String getStyle(Table source, Object itemId,
                    Object propertyId) {
                if (propertyId != null && propertyId.equals("red")) {
                    return "red";
                } else if (itemId.equals("blue") && propertyId == null) {
                    // row style
                    return "blue";
                }
                return null;
            }

        };

        Table table = new Table();
        table.addContainerProperty("foo", String.class, "foo");
        table.addContainerProperty("red", String.class, "red");
        table.addItem();
        table.addItem("blue");
        table.setCellStyleGenerator(g);

        addComponent(table);

        table = new Table();
        table.addContainerProperty("foo", String.class, "foo");
        table.addContainerProperty("red", String.class, "red");
        table.addItem();
        table.addItem("blue");
        table.setCellStyleGenerator(g);
        table.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);

        addComponent(table);

    }

    @Override
    protected String getDescription() {
        return "Cell style generators should work";
    }

    @Override
    protected Integer getTicketNumber() {
        return null;
    }

}
TOP

Related Classes of com.vaadin.tests.components.table.CellStyleGeneratorTest

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.