Search in sources :

Example 1 with Resources

use of org.gwtproject.user.cellview.client.CellTable.Resources in project gwtproject by treblereel.

the class CellTableTest method testMultiColumnHeader.

/**
 * Test headers that span multiple columns.
 */
public void testMultiColumnHeader() {
    Resources res = new CellTable_ResourcesImpl();
    CellTable<String> table = new CellTable<>(10, res);
    TextHeader header = new TextHeader("Hello");
    // Get the style information.
    Style style = res.cellTableStyle();
    String styleHeader = style.cellTableHeader();
    String styleFirstColumn = style.cellTableFirstColumnHeader();
    String styleLastColumn = style.cellTableLastColumnHeader();
    // No header.
    table.redraw();
    table.getPresenter().flush();
    assertEquals(0, getHeaderCount(table));
    // Single column.
    table.addColumn(new TextColumn<String>() {

        @Override
        public String getValue(String object) {
            return null;
        }
    }, header);
    table.getPresenter().flush();
    assertEquals(1, getHeaderCount(table));
    assertEquals(1, getHeaderElement(table, 0).getColSpan());
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleHeader));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleFirstColumn));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleLastColumn));
    // Header spans both columns.
    table.addColumn(new TextColumn<String>() {

        @Override
        public String getValue(String object) {
            return null;
        }
    }, header);
    table.getPresenter().flush();
    assertEquals(1, getHeaderCount(table));
    assertEquals(2, getHeaderElement(table, 0).getColSpan());
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleHeader));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleFirstColumn));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleLastColumn));
    // Header spans all three columns.
    table.addColumn(new TextColumn<String>() {

        @Override
        public String getValue(String object) {
            return null;
        }
    }, header);
    table.getPresenter().flush();
    assertEquals(1, getHeaderCount(table));
    assertEquals(3, getHeaderElement(table, 0).getColSpan());
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleHeader));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleFirstColumn));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleLastColumn));
    // New header at fourth column.
    table.addColumn(new TextColumn<String>() {

        @Override
        public String getValue(String object) {
            return null;
        }
    }, "New Header");
    table.getPresenter().flush();
    assertEquals(2, getHeaderCount(table));
    assertEquals(3, getHeaderElement(table, 0).getColSpan());
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleHeader));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleFirstColumn));
    assertEquals(1, getHeaderElement(table, 1).getColSpan());
    assertTrue(getHeaderElement(table, 1).getClassName().contains(styleHeader));
    assertTrue(getHeaderElement(table, 1).getClassName().contains(styleLastColumn));
    // Two separate spans of same header: HHHXHH.
    table.addColumn(new TextColumn<String>() {

        @Override
        public String getValue(String object) {
            return null;
        }
    }, header);
    table.addColumn(new TextColumn<String>() {

        @Override
        public String getValue(String object) {
            return null;
        }
    }, header);
    table.getPresenter().flush();
    assertEquals(3, getHeaderCount(table));
    assertEquals(3, getHeaderElement(table, 0).getColSpan());
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleHeader));
    assertTrue(getHeaderElement(table, 0).getClassName().contains(styleFirstColumn));
    assertEquals(1, getHeaderElement(table, 1).getColSpan());
    assertTrue(getHeaderElement(table, 1).getClassName().contains(styleHeader));
    assertEquals(2, getHeaderElement(table, 2).getColSpan());
    assertTrue(getHeaderElement(table, 2).getClassName().contains(styleHeader));
    assertTrue(getHeaderElement(table, 2).getClassName().contains(styleLastColumn));
}
Also used : Style(org.gwtproject.user.cellview.client.CellTable.Style) Resources(org.gwtproject.user.cellview.client.CellTable.Resources)

Example 2 with Resources

use of org.gwtproject.user.cellview.client.CellTable.Resources in project gwtproject by treblereel.

the class CellTableTest method testNullSortIcons.

/**
 * Using a null sort icon should not cause any errors if none of the columns
 * are sortable.
 */
public void testNullSortIcons() {
    // Create a Resources instance that does not include sort images.
    CellTable.Resources resources = new CellTable.Resources() {

        private final CellTable.Resources defaultRes = new CellTable_ResourcesImpl();

        @Override
        public ImageResource cellTableFooterBackground() {
            return defaultRes.cellTableFooterBackground();
        }

        @Override
        public ImageResource cellTableHeaderBackground() {
            return defaultRes.cellTableHeaderBackground();
        }

        @Override
        public ImageResource cellTableLoading() {
            return defaultRes.cellTableLoading();
        }

        @Override
        public ImageResource cellTableSelectedBackground() {
            return defaultRes.cellTableSelectedBackground();
        }

        @Override
        public ImageResource cellTableSortAscending() {
            return null;
        }

        @Override
        public ImageResource cellTableSortDescending() {
            return null;
        }

        @Override
        public Style cellTableStyle() {
            return defaultRes.cellTableStyle();
        }
    };
    CellTable<String> table = new CellTable<String>(10, resources);
    populateData(table);
    table.getPresenter().flush();
}
Also used : Resources(org.gwtproject.user.cellview.client.CellTable.Resources) Resources(org.gwtproject.user.cellview.client.CellTable.Resources)

Example 3 with Resources

use of org.gwtproject.user.cellview.client.CellTable.Resources in project gwtproject by treblereel.

the class CellTableTest method testNullLoadingImage.

public void testNullLoadingImage() {
    // Create a Resources instance that does not include a loading image.
    CellTable.Resources resources = new CellTable.Resources() {

        private final CellTable.Resources defaultRes = new CellTable_ResourcesImpl();

        @Override
        public ImageResource cellTableFooterBackground() {
            return defaultRes.cellTableFooterBackground();
        }

        @Override
        public ImageResource cellTableHeaderBackground() {
            return defaultRes.cellTableHeaderBackground();
        }

        @Override
        public ImageResource cellTableLoading() {
            return null;
        }

        @Override
        public ImageResource cellTableSelectedBackground() {
            return defaultRes.cellTableSelectedBackground();
        }

        @Override
        public ImageResource cellTableSortAscending() {
            return defaultRes.cellTableSortAscending();
        }

        @Override
        public ImageResource cellTableSortDescending() {
            return defaultRes.cellTableSortDescending();
        }

        @Override
        public Style cellTableStyle() {
            return defaultRes.cellTableStyle();
        }
    };
    CellTable<String> table = new CellTable<String>(25, resources);
    assertNull(table.getLoadingIndicator());
}
Also used : Resources(org.gwtproject.user.cellview.client.CellTable.Resources) Resources(org.gwtproject.user.cellview.client.CellTable.Resources)

Example 4 with Resources

use of org.gwtproject.user.cellview.client.CellTable.Resources in project gwtproject by treblereel.

the class CellTableTest method testNullIcons.

/**
 * CellTable should not throw any errors if all of the icons are null.
 *
 * Sort icons are only used if a column is sorted. Background icons are not
 * used in the default styles, and are optional. The sorting icon is specially
 * handled.
 */
public void testNullIcons() {
    // Create a Resources instance that does not include sort images.
    CellTable.Resources resources = new CellTable.Resources() {

        private final CellTable.Resources defaultRes = new CellTable_ResourcesImpl();

        @Override
        public ImageResource cellTableFooterBackground() {
            return null;
        }

        @Override
        public ImageResource cellTableHeaderBackground() {
            return null;
        }

        @Override
        public ImageResource cellTableLoading() {
            return null;
        }

        @Override
        public ImageResource cellTableSelectedBackground() {
            return null;
        }

        @Override
        public ImageResource cellTableSortAscending() {
            return null;
        }

        @Override
        public ImageResource cellTableSortDescending() {
            return null;
        }

        @Override
        public Style cellTableStyle() {
            return defaultRes.cellTableStyle();
        }
    };
    CellTable<String> table = new CellTable<String>(10, resources);
    populateData(table);
    table.getPresenter().flush();
}
Also used : Resources(org.gwtproject.user.cellview.client.CellTable.Resources) Resources(org.gwtproject.user.cellview.client.CellTable.Resources)

Example 5 with Resources

use of org.gwtproject.user.cellview.client.CellTable.Resources in project gwtproject by treblereel.

the class CellTableTest method testTableWidgetStyle.

/**
 * Test if the tableWidget style is applied.
 */
public void testTableWidgetStyle() {
    Resources res = new CellTable_ResourcesImpl();
    CellTable<String> table = new CellTable<String>(10, res);
    String tableWidgetStyle = res.cellTableStyle().cellTableWidget();
    TableElement tableElem = table.getElement().cast();
    assertTrue(tableElem.getClassName().contains(tableWidgetStyle));
}
Also used : Resources(org.gwtproject.user.cellview.client.CellTable.Resources) TableElement(org.gwtproject.dom.client.TableElement)

Aggregations

Resources (org.gwtproject.user.cellview.client.CellTable.Resources)5 TableElement (org.gwtproject.dom.client.TableElement)1 Style (org.gwtproject.user.cellview.client.CellTable.Style)1