import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

public class TestModule implements EntryPoint //Don't extend WebModule when sending to vendor
{
    private static String[][] cellValues = new String[][] {
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " } };

    public void onModuleLoad()
    {
        RootPanel root = RootPanel.get("content");
        root.add(getMainPanel());
    }

    public Panel getMainPanel()
    {
        ListGrid grid = new ListGrid()
        {
            protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum)
            {
                if (rowNum == 0)
                {
                    return "padding-left: 45px;";
                }
                return super.getCellCSSText(record, rowNum, colNum);
            }
        };
        grid.setWrapCells(true);
        ListGridField frozenField = new ListGridField("frozen1");
        frozenField.setFrozen(true);
        frozenField.setMaxWidth(200);

        ListGridField frozenField2 = new ListGridField("frozen2");
        frozenField2.setFrozen(true);
        frozenField2.setMaxWidth(200);

        ListGridField unfrozenField = new ListGridField("unfrozen");
        unfrozenField.setMinWidth(80);

        grid.setWrapCells(true);
        grid.setFixedRecordHeights(false);
        grid.setFields(frozenField, unfrozenField);

        ArrayList<TestRecord> records = new ArrayList<TestRecord>();
        for (String[] row : cellValues)
        {
            TestRecord record = new TestRecord(row);
            records.add(record);
        }
        grid.setRecords(records.toArray(new ListGridRecord[0]));
        grid.setHeight("75%");
        grid.setWidth("98%");

        FlowPanel panel = new FlowPanel();
        panel.setHeight("100%");
        panel.setWidth("100%");
        panel.add(grid);
        return panel;
    }

    private class TestRecord extends ListGridRecord
    {
        public TestRecord(String[] values)
        {
            this.setAttribute("frozen1", values[0]);
            this.setAttribute("frozen2", values[1]);
            this.setAttribute("unfrozen", values[2]);
        }
    }

}
