Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.test.uidesign.client;

import org.litesoft.GWT.client.widgets.datatables.*;

import com.google.gwt.user.client.ui.*;

public class TestTable
{
    public static class RowObject
    {
        private static int nextID = 0;

        private int mID;
        private String mName;
        private String mDescription;

        public RowObject( String pName, String pDescription )
        {
            synchronized ( RowObject.class )
            {
                mID = nextID++;
            }
            mName = pName;
            mDescription = pDescription;
        }

        public Integer getID()
        {
            return mID;
        }

        public String getName()
        {
            return mName;
        }

        public String getDescription()
        {
            return mDescription;
        }

        @Override
        public String toString()
        {
            return mName;
        }

        @Override
        public int hashCode()
        {
            return mID;
        }

        public boolean equals( RowObject them )
        {
            return (this == them) || ((them != null) && (this.mID == them.mID));
        }

        @Override
        public boolean equals( Object o )
        {
            return (this == o) || ((o instanceof RowObject) && equals( (RowObject) o ));
        }
    }

    public static Widget create()
    {
        ListTableModel<RowObject> zListTableModel = new ListTableModel<RowObject>();
        zListTableModel.add( new RowObject( "Fred", "Comedic Lead" ) );
        zListTableModel.add( new RowObject( "Wilma", "Fred's Better 5/6" ) );
        zListTableModel.add( new RowObject( "Barney", "Comedic Support" ) );
        zListTableModel.add( new RowObject( "Betty", "Barney's Wife" ) );
        zListTableModel.add( new RowObject( "Pebbles", "Spawn of Fred & Wilma" ) );
        zListTableModel.add( new RowObject( "Bam Bam", "Adopted Son of Barney & Betty" ) );

        return new SingleSelectRegularTable<RowObject>( zListTableModel, new TableDef(), new TableClickCommand<RowObject>()
        {
            @Override
            public void execute( RowObject pRowValue )
            {
                System.out.println( "Clicked: " + pRowValue );
            }
        } );
    }

    private static class TableDef extends TableDefinitionPlus<RowObject>
    {
        public TableDef()
        {
            addColumnDefinition( new TableColumnDefinition<RowObject>( "Name" )
            {
                @Override
                public Object getCellValue( RowObject rowValue )
                {
                    return rowValue.getName();
                }
            } );
            addColumnDefinition( new TableColumnDefinition<RowObject>( "Description" )
            {
                @Override
                public Object getCellValue( RowObject rowValue )
                {
                    return rowValue.getDescription();
                }
            } );
        }
    }
}

Commits for litesoft/trunk/GWT_Sandbox/UIdesign/src/com/test/uidesign/client/TestTable.java

Diff revisions: vs.
Revision Author Commited Message
613 GeorgeS picture GeorgeS Thu 15 Mar, 2012 13:38:15 +0000

Table Fix