package com.utilinc.planner.gwt.web.client;

import java.util.ArrayList;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HLayout;

public class TestModule implements EntryPoint
{
    private static String[][] cellValues = new String[][] { { "BSOW9CCC", "Grid Configurations", "7,545 " },
            { "BSOW9CCC", "Projects Configuration", "67,655 " }, { "BSOW9CCC", "Reporting", "9,545 " },
            { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " },
            { "BUD66CCC", "BGRID ",
                    " Budget Grid Configuration Budget Grid Configuration Budget Grid Configuration Budget Grid Configuration Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " }, { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " }, { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " }, { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " }, { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " }, { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " }, { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " },
            { "BSOW9CCC", "Grid Configurations", "7,545 " }, { "BSOW9CCC", "Projects Configuration", "67,655 " },
            { "BSOW9CCC", "Reporting", "9,545 " }, { "BUD66CCC", "BGRID ", " Budget Grid Configuration", },
            { "BUD66CCC", "DESGN ", " Design Docs", "646,555 " },
            { "BUD66CCC", "DOCUM ", " Documentation (User Manual; Admin Manual)", "6,555 " },
            { "BUD66CCC", "INFRA ", " Hardware Infrastructure (Servers; Database Setup)", "69,455 " },
            { "BUD66CCC", "INTXX ", " Interfaces (General)", "45,555 " },
            { "BUD66CCC", "LABOR ", " Babor Screen/Calc", "4,655 " },
            { "BUD66CCC", "LDGS ", " Live (Grid) Loadings", "46,555 " },
            { "BUD66CCC", "MERGE ", " Merge Actuals", "66,955 " },
            { "BUD66CCC", "PMGMT ", " Project Management", "49,955 " },
            { "BUD66CCC", "PSPPT ", " Product Support (Code/WAR Files; New Releases)", "64,555 " },
            { "BUD66CCC", "RPRTS ", " Creation of B4ii Pivot Reports", "9,555 " },
            { "BUD66CCC", "UTEST ", " Unit Testing", "65,555 " }, { "Design Documentation Support", "665,455 " },
            { "Integration/Interface Configuration", "65,545 " }, { "Labor Configuration", "7,545 " } };

    public void onModuleLoad()
    {
        Canvas p = getMainPanel();
        p.draw();
    }


    public Canvas getMainPanel()
    {
        ListGrid grid = new ListGrid()
        {
            protected String getCellStyle(ListGridRecord record, int row, int column)
            {
                //  Not necessary to reproduce the bug, but it helps you see them row misalignment. CSS at the top of the file.
                String sup = super.getCellStyle(record, row, column);
                return "borderedCell " + sup;
            }
        };
        ListGridField frozenField = new ListGridField("frozen1");
        // frozenField.setFrozen(true);
        frozenField.setWidth(100);

        ListGridField unfrozenField = new ListGridField("unfrozen");
        unfrozenField.setWidth(100);

        grid.setWrapCells(true);
        grid.setFixedRecordHeights(false);
        grid.setCanFreezeFields(true);
        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%");

        //        HLayout h = new HLayout();
        //        h.setWidth100();
        //        h.setHeight100();
        //        return h;

        HLayout panel = new HLayout();
        panel.addMember(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]);
        }
    }

}
