Search in sources :

Example 1 with DataViewBase

use of org.apache.wicket.markup.repeater.data.DataViewBase in project midpoint by Evolveum.

the class CountToolbar method createModel.

private IModel<String> createModel() {
    return new LoadableModel<String>() {

        @Override
        protected String load() {
            long from = 0;
            long to = 0;
            long count = 0;
            IPageable pageable = getTable();
            if (pageable instanceof DataViewBase) {
                DataViewBase view = (DataViewBase) pageable;
                from = view.getFirstItemOffset() + 1;
                to = from + view.getItemsPerPage() - 1;
                long itemCount = view.getItemCount();
                if (to > itemCount) {
                    to = itemCount;
                }
                count = itemCount;
            } else if (pageable instanceof DataTable) {
                DataTable table = (DataTable) pageable;
                from = table.getCurrentPage() * table.getItemsPerPage() + 1;
                to = from + table.getItemsPerPage() - 1;
                long itemCount = table.getItemCount();
                if (to > itemCount) {
                    to = itemCount;
                }
                count = itemCount;
            }
            if (count > 0) {
                PageBase.createStringResourceStatic(CountToolbar.this, "CountToolbar.label", new Object[] { from, to, count });
            }
            return PageBase.createStringResourceStatic(CountToolbar.this, "CountToolbar.noFound").getString();
        }
    };
}
Also used : DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) DataViewBase(org.apache.wicket.markup.repeater.data.DataViewBase) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) IPageable(org.apache.wicket.markup.html.navigation.paging.IPageable)

Aggregations

LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 DataTable (org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable)1 IPageable (org.apache.wicket.markup.html.navigation.paging.IPageable)1 DataViewBase (org.apache.wicket.markup.repeater.data.DataViewBase)1