@Override protected void createColumns( DefaultCellTable<Transformer> table, ListDataProvider<Transformer> dataProvider) { TextColumn<Transformer> fromColumn = new TextColumn<Transformer>() { @Override public String getValue(Transformer transform) { return transform.getFrom(); } }; fromColumn.setSortable(true); TextColumn<Transformer> toColumn = new TextColumn<Transformer>() { @Override public String getValue(Transformer transform) { return transform.getTo(); } }; toColumn.setSortable(true); TextColumn<Transformer> typeColumn = new TextColumn<Transformer>() { @Override public String getValue(Transformer transform) { return transform.getType(); } }; typeColumn.setSortable(true); ColumnSortEvent.ListHandler<Transformer> sortHandler = new ColumnSortEvent.ListHandler<Transformer>(dataProvider.getList()); sortHandler.setComparator(fromColumn, createColumnCommparator(fromColumn)); sortHandler.setComparator(toColumn, createColumnCommparator(toColumn)); sortHandler.setComparator(typeColumn, createColumnCommparator(typeColumn)); table.addColumn(fromColumn, "From"); table.addColumn(toColumn, "To"); table.addColumn(typeColumn, "Type"); table.addColumnSortHandler(sortHandler); table.getColumnSortList().push(typeColumn); table.getColumnSortList().push(toColumn); table.getColumnSortList().push(fromColumn); table.setWidth("100%", false); table.setColumnWidth(fromColumn, 45, Style.Unit.PCT); table.setColumnWidth(toColumn, 45, Style.Unit.PCT); table.setColumnWidth(typeColumn, 10, Style.Unit.PCT); }
@SuppressWarnings("unchecked") @Override protected void createColumns( DefaultCellTable<ArtifactReference> table, ListDataProvider<ArtifactReference> dataProvider) { final TextColumn<ArtifactReference> nameColumn = new TextColumn<ArtifactReference>() { @Override public String getValue(ArtifactReference reference) { return reference.getName(); } }; nameColumn.setSortable(true); final TextColumn<ArtifactReference> urlColumn = new TextColumn<ArtifactReference>() { @Override public String getValue(ArtifactReference reference) { return reference.getUrl(); } }; urlColumn.setSortable(true); ColumnSortEvent.ListHandler<ArtifactReference> sortHandler = new ColumnSortEvent.ListHandler<ArtifactReference>(dataProvider.getList()); sortHandler.setComparator(nameColumn, createColumnCommparator(nameColumn)); sortHandler.setComparator(urlColumn, createColumnCommparator(urlColumn)); table.addColumn(nameColumn, "Name"); table.addColumn(urlColumn, "URL"); table.addColumnSortHandler(sortHandler); table.addColumnSortHandler(sortHandler); table.getColumnSortList().push(urlColumn); table.getColumnSortList().push(nameColumn); }