At the 2010 Google IO it was announced that GWT 2.1 would include new Data Presentation Widgets. 2.1M is available for download, and presumably the widgets are included, but
I have a working prototype of an editable CellTable. The prototype has a Table displaying String, Boolean, Date, Integer columns with editors for each. Editing each cell updates the corresponding model.
public class CellTableDemo implements EntryPoint
{
public void onModuleLoad( )
{
CellTable cellTable = createTable( );
addColumns( cellTable );
ListViewAdapter listViewAdapter = new ListViewAdapter( );
listViewAdapter.setList( getData( ) );
listViewAdapter.addView( cellTable );
RootPanel.get( ).add( new SimplePager( cellTable, SimplePager.TextLocation.CENTER ) );
RootPanel.get( ).add( cellTable );
}
private CellTable createTable( )
{
CellTable cellTable = new CellTable( );
cellTable.setSelectionEnabled( true );
cellTable.setSelectionModel( new SingleSelectionModel( ) );
cellTable.setPageSize( 5 );
cellTable.setPageStart( 0 );
return cellTable;
}
private void addColumns( CellTable cellTable )
{
Column colA = new Column( new TextInputCell( ) )
{
public String getValue( SomeDTO object )
{
return object.getA( );
}
};
colA.setFieldUpdater( new FieldUpdater( ) // updates changes into the backing bean
{
public void update( int index, SomeDTO object, String value )
{
object.setA( value );
}
} );
cellTable.addColumn( colA, "String Column A" );
cellTable.addColumn( new Column( new CurrencyCell( ) )
{
public Integer getValue( SomeDTO object )
{
return object.getB( );
}
}, "Currency Column B" );
Column colC = new Column( new CheckboxCell( ) )
{
public Boolean getValue( SomeDTO object )
{
return object.getC( );
}
};
colC.setFieldUpdater( new FieldUpdater( )
{
public void update( int index, SomeDTO object, Boolean value )
{
object.setC( value );
}
} );
cellTable.addColumn( colC, "Boolean Column C" );
Column colD = new Column( new DatePickerCell( ) )
{
public Date getValue( SomeDTO object )
{
return object.getD( );
}
};
colD.setFieldUpdater( new FieldUpdater( )
{
public void update( int index, SomeDTO object, Date value )
{
object.setD( value );
}
} );
cellTable.addColumn( colD, "Date Column D" );
cellTable.addColumn( new Column( new ActionCell( "Click of summary of this row", new Delegate( )
{
public void execute( String row )
{
Window.alert( row );
}
} ) )
{
public String getValue( SomeDTO row )
{
return row.getSummary( );
}
} );
}
private ArrayList getData( )
{
ArrayList tableData = new ArrayList( );
tableData.add( new SomeDTO( "A", 10, true, new Date( ) ) );
tableData.add( new SomeDTO( "AA", 200, false, new Date( ) ) );
tableData.add( new SomeDTO( "AAA", 3000, true, new Date( ) ) );
tableData.add( new SomeDTO( "AAAA", 40, false, new Date( ) ) );
tableData.add( new SomeDTO( "AAAAA", 500, true, new Date( ) ) );
tableData.add( new SomeDTO( "AAAAAA", 6000, false, new Date( ) ) );
tableData.add( new SomeDTO( "AAAAAAA", 70, true, new Date( ) ) );
tableData.add( new SomeDTO( "AAAAAAAA", 800, false, new Date( ) ) );
tableData.add( new SomeDTO( "AAAAAAAAA", 9000, true, new Date( ) ) );
tableData.add( new SomeDTO( "AAAAAAAAAA", 10, false, new Date( ) ) );
tableData.add( new SomeDTO( "AAAAAAAAAAA", 11, true, new Date( ) ) );
return tableData;
}
public class SomeDTO
{
private String a;
private Integer b;
private Boolean c;
private Date d;
public SomeDTO( String a, Integer b, Boolean c, Date d )
{
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
public String getA( )
{
return a;
}
public void setA( String a )
{
this.a = a;
}
public Integer getB( )
{
return b;
}
public void setB( Integer b )
{
this.b = b;
}
public Boolean getC( )
{
return c;
}
public void setC( Boolean c )
{
this.c = c;
}
public Date getD( )
{
return d;
}
public void setD( Date d )
{
this.d = d;
}
public String getSummary( )
{
return getA( ) + " " + getB( ) + " " + getC( ) + " " + getD( );
}
}
}