That being said, you said "RFC"...so... :-)
> This approach ties the column width to the view, not to the Column
> itself, so users can use different widths for mobile and desktop
> views.
Personally, I'd rather just do:
column.setWidth(20, Unit.PX);
Than the ColumnsWidths abstraction.
...besides, in canonical GWT MVP, wouldn't you do something like:
interface XxxView { HasData<T> table(); }
class MobileView {
void foo() {
columnA.setWidth(20, Unit.PX);
}
}
class DesktopView {
void foo() {
columnA.setWidth(200, Unit.PX);
}
}
...are you really going to want to share widths across desktop/web? Or,
even if you do, should that be something your presenter worries about?
I suppose if the widths relative--but even if the widths are relative,
it still seems like that is a code reuse concern between the views, and
not something the presenter should be concerned about.
(Look at that, Column is even an abstract class, so you can add setWidth
without a breaking change. ;-) )
- Stephen
Hm, would a CellTable overload of setWidth be good enough, e.g.:
table.setWidth(String width, boolean isFixed);
This seems more discoverable than the get/setLayoutFixed toggle that,
I agree as you mentioned, might get lost in the CellTable method list.
- Stephen
Hm, would a CellTable overload of setWidth be good enough, e.g.:
> We could JavaDoc it, but I wish it was more discoverable in the API.
table.setWidth(String width, boolean isFixed);
This seems more discoverable than the get/setLayoutFixed toggle that,
I agree as you mentioned, might get lost in the CellTable method list.
Minor suggestion but would not ColumnWidthSource be a better name than ColumnWidths, after all it is a source of column widths given a column. When i see classes w/ plural names, i think of classes w/ static helpers java.util.Collections. Guice is another example of this naming style.
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. I suppose a helper method would work:
addColumn(table, makeFirstColumn(), 20, PX);
private void addColumn(CellTable<T> t, Column<T, ?> c, int, unit) {
t.addColumn(c);
c.setColumnWidth(int, unit);
}
Eh.
> 1. We don't need a CellTable#refreshColumnWidths() method because
> CellTable always knows when the width changes.
True, this is nice, although there is precedence of having to call refresh
header/footer is you change things post-render.
> 2. I'm not 100% sold on Column#setWidth() because its possible to use the
> same column in two tables but have different widths.
...true, but it seems like a pretty small boundary case.
Nonetheless, I look forward to using the functionality.
Thanks!
- Stephen
> 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 readprivate 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.
Hi, I need to use this patch, but I'm really losed about how to download and use it.
How must I install this patch in my enviroment?