On Thursday, January 6, 2011 11:34:17 PM UTC+1, Stephen Haberman wrote:
>
>
> > CellTable.setColumnWidth(Column col, double width, Unit unit)
>
> Yeah, I like this better.
>
> That being said, I still prefer setWidth, because, thinking how
> I'd create a table, with col.setWidth, I could do:
>
> table.addColumn(makeFirstColumn());
> table.addColumn(makeSecondColumn());
> // ... more 1-line addColumn calls, which are easy to read
>
> private Column makeFirstColumn() {
> Column c = new Column() { ... };
> c.setWidth(...);
> return c;
> }
>
> Where as with a separate setColumnWidth call, I'll have to:
>
> Column<T, ?> c1 = makeFirstColumn();
> table.addColumn(c1);
> table.setColumnWidth(c1, 20, PX);
>
> Column<T, ?> c2 = makeSecondColumn();
> table.addColumn(c2);
> table.setColumnWidth(c2, 20, PX);
>
> private Column makeFirstColumn() {
> Column c = new Column() { ... };
> return c;
> }
>
> Basically, keeping track of the c1, c2 variables obfuscates the
> table.addColumn calls.
>
You would probably refactor your code with an addFirstColumn(CellTable)
method instead that creates the Column, sets its width and adds it to the
CellTable.
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors