Search in sources :

Example 1 with IExportableColumn

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;
}
Also used : IExportableColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.export.IExportableColumn) IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Item(org.apache.wicket.markup.repeater.Item) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 2 with IExportableColumn

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;
}
Also used : IExportableColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.export.IExportableColumn) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 IExportableColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.export.IExportableColumn)2 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)1 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 SelectableListDataProvider (com.evolveum.midpoint.web.component.util.SelectableListDataProvider)1 AbstractColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 Item (org.apache.wicket.markup.repeater.Item)1 IModel (org.apache.wicket.model.IModel)1 StringResourceModel (org.apache.wicket.model.StringResourceModel)1