use of org.apache.wicket.extensions.markup.html.repeater.data.table.export.IExportableColumn in project midpoint by Evolveum.
the class ExportingPanel method createTable.
private BoxedTablePanel<SelectableBean<Integer>> createTable(String id, DataTable<?, ?> dataTable) {
List<? extends IColumn<?, ?>> allColumns = dataTable.getColumns();
List<Integer> exportableColumnIndex = getExportableColumns(dataTable);
if (exportableColumnIndex.isEmpty()) {
throw new IllegalArgumentException("List of exportable columns is empty");
}
List<IColumn<SelectableBean<Integer>, String>> columns = new ArrayList<>();
CheckBoxHeaderColumn<SelectableBean<Integer>> checkboxColumn = new CheckBoxHeaderColumn<>();
columns.add(checkboxColumn);
StringResourceModel nameString = getPageBase().createStringResource("ExportingPopupPanel.nameColumn");
IColumn<SelectableBean<Integer>, String> nameColumn = new AbstractColumn<SelectableBean<Integer>, String>(nameString) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<Integer>>> cellItem, String componentId, IModel<SelectableBean<Integer>> rowModel) {
IModel stringModel = ((IExportableColumn) allColumns.get(rowModel.getObject().getValue())).getDisplayModel();
cellItem.add(new Label(componentId, stringModel));
}
};
columns.add(nameColumn);
SelectableListDataProvider<SelectableBean<Integer>, Integer> provider = new SelectableListDataProvider<SelectableBean<Integer>, Integer>(getPageBase(), Model.ofList(exportableColumnIndex)) {
@Override
public Iterator<SelectableBean<Integer>> internalIterator(long first, long count) {
if (getAvailableData().isEmpty()) {
return super.internalIterator(first, count);
} else {
return getAvailableData().iterator();
}
}
};
BoxedTablePanel<SelectableBean<Integer>> table = new BoxedTablePanel<SelectableBean<Integer>>(id, provider, columns) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new WebMarkupContainer(headerId);
}
@Override
public String getAdditionalBoxCssClasses() {
return null;
}
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
return new WebMarkupContainer(id);
}
@Override
protected boolean hideFooterIfSinglePage() {
return true;
}
@Override
public int getAutoRefreshInterval() {
return 0;
}
@Override
public boolean isAutoRefreshEnabled() {
return false;
}
};
table.setOutputMarkupId(true);
return table;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.export.IExportableColumn in project midpoint by Evolveum.
the class ExportingPanel method getExportableColumns.
private List<Integer> getExportableColumns(DataTable<?, ?> dataTable) {
List<? extends IColumn<?, ?>> columns = dataTable.getColumns();
List<Integer> exportableColumn = new ArrayList<>();
for (IColumn column : columns) {
if (column instanceof IExportableColumn) {
exportableColumn.add(columns.indexOf(column));
}
}
return exportableColumn;
}
Aggregations