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();
}
};
}
Aggregations