litesoft
@ 939
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 |
package org.litesoft.mgwt.client.widgets; import java.util.*; import org.litesoft.commonfoundation.annotations.*; import org.litesoft.core.util.*; import org.litesoft.core.util.externalization.*; import com.googlecode.mgwt.ui.client.widget.celllist.BasicCell; import com.googlecode.mgwt.ui.client.widget.celllist.*; public class OptionList<T> extends AbstractOptionListWidget<T> { private final CellListWithHeader<T> mListWithHeader; public OptionList( @NotNull E13nResolver pResolver, @Nullable SelectedListener<T> pSelectedListener ) { super( pResolver, pSelectedListener ); mListWithHeader = new CellListWithHeader<T>( new BasicCell<T>() { @Override public String getDisplayString( T pOption ) { return DisplayObject.resolve( mResolver, pOption ); } @Override public boolean canBeSelected( T pOption ) { return isSelectable( pOption ); } } ); mListWithHeader.getCellList().addCellSelectedHandler( new CellSelectedHandler() { @Override public void onCellSelected( CellSelectedEvent event ) { processSelectedIndex( event.getIndex() ); } } ); initWidget( mListWithHeader ); } public OptionList( @NotNull E13nResolver pResolver ) { this( pResolver, null ); } public OptionList<T> round() { mListWithHeader.getCellList().setRound( true ); return this; } public OptionList<T> header( Object pHeaderTextSource ) { mListWithHeader.getHeader().setText( DisplayObject.resolve( mResolver, pHeaderTextSource ) ); return this; } public OptionList<T> options( @Nullable List<T> pOptions ) { setOptions( pOptions ); return this; } public OptionList<T> options( @Nullable T... pOptions ) { setOptions( pOptions ); return this; } @Override protected void optionsUpdated( @NotNull List<T> pOptions ) { mListWithHeader.getCellList().render( pOptions ); } } |