Java Code Examples for com.google.gwt.user.client.ui.Grid#getCellFormatter()

The following examples show how to use com.google.gwt.user.client.ui.Grid#getCellFormatter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WordCloudLatestApp.java    From swcv with MIT License 6 votes vote down vote up
private Grid createStatTable(DBStatistics result)
{
    Grid table = new Grid(3, 2);
    table.addStyleName("stat");

    table.setHTML(0, 0, "the number of clouds <b>in total</b>");
    table.setHTML(1, 0, "the number of clouds constructed <b>last month</b>");
    table.setHTML(2, 0, "the number of clouds constructed <b>last week</b>");

    table.setHTML(0, 1, "" + result.getTotal());
    table.setHTML(1, 1, "" + result.getLastMonth());
    table.setHTML(2, 1, "" + result.getLastWeek());

    CellFormatter cf = table.getCellFormatter();
    cf.setWidth(0, 0, "65%");
    cf.setWidth(0, 1, "35%");
    return table;
}
 
Example 2
Source File: WordCloudLatestApp.java    From swcv with MIT License 4 votes vote down vote up
private Grid createTable(List<WordCloud> clouds, boolean debug)
{
    Grid table = new Grid(clouds.size() + 1, debug ? 4 : 3);
    table.addStyleName("latest");
    CellFormatter cf = table.getCellFormatter();

    table.setHTML(0, 0, "<b>id</b>");
    table.setHTML(0, 1, "<b>creation date</b>");
    table.setHTML(0, 2, "<b>source</b>");
    cf.setWidth(0, 0, "10%");
    cf.setWidth(0, 1, "25%");
    cf.setWidth(0, 2, "65%");
    cf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
    cf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    cf.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);

    if (debug)
    {
        table.setHTML(0, 3, "<b>ip</b>");
        cf.setWidth(0, 1, "20%");
        cf.setWidth(0, 2, "60%");
        cf.setWidth(0, 3, "10%");
        cf.setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
    }

    for (int i = 0; i < clouds.size(); i++)
    {
        WordCloud cloud = clouds.get(i);

        table.setHTML(i + 1, 0, "<a href='/cloud.html?id=" + cloud.getId() + "'>" + cloud.getId() + "</a>");
        Date dt = cloud.getCreationDateAsDate();
        table.setHTML(i + 1, 1, DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(dt));
        table.setWidget(i + 1, 2, createSourceField(cloud, debug));
        cf.setHorizontalAlignment(i + 1, 2, HasHorizontalAlignment.ALIGN_LEFT);

        if (debug)
        {
            table.setHTML(i + 1, 3, cloud.getCreatorIP());
        }
    }

    return table;
}