litesoft
@ 948
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / widget / table / column / TextDataColumn.java
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 |
package com.temp.client.foundation.widget.table.column; import com.google.gwt.cell.client.Cell.*; import com.google.gwt.safehtml.shared.*; import com.google.gwt.user.cellview.client.*; import com.temp.client.foundation.widget.table.*; import com.temp.client.foundation.widget.table.cell.*; import com.temp.shared.utils.*; public class TextDataColumn<R extends DataRow<F>, F> extends Column<R, String> implements DataColumn { private F field; private CellDecorator<R> cellDecorator; public TextDataColumn( F field ) { this( field, false, false ); } public TextDataColumn( F field, boolean isSortable ) { this( field, isSortable, false ); } public TextDataColumn( F field, boolean isSortable, boolean isNumeric ) { //super(new TextCell()); super( new TextDataCell<String>() ); this.field = field; setSortable( isSortable ); if ( isNumeric ) { setHorizontalAlignment( ALIGN_RIGHT ); } if ( field instanceof CellDecorator ) { cellDecorator = ObjectUtils.cast( field ); } if ( field instanceof CellDecoratorAccessor ) { CellDecoratorAccessor<R> accessor = ObjectUtils.cast( field ); cellDecorator = accessor.getCellDecorator(); } } @Override public String getFieldString() { return field.toString(); } @Override public String getValue( R rowData ) { return rowData.getNonNullValueString( field ); } public void render( Context context, R object, SafeHtmlBuilder sb ) { if ( cellDecorator == null ) { super.render( context, object, sb ); } else { cellDecorator.prepend( context, object, sb ); super.render( context, object, sb ); cellDecorator.append( context, object, sb ); } } } |