use of org.apache.wicket.util.iterator.ComponentHierarchyIterator in project midpoint by Evolveum.
the class CheckBoxHeaderColumn method onUpdateHeader.
/**
* This method is called after select all checkbox is clicked
* @param target
* @param selected
* @param table
*/
protected void onUpdateHeader(AjaxRequestTarget target, boolean selected, DataTable table) {
IDataProvider provider = table.getDataProvider();
if (!(provider instanceof BaseSortableDataProvider)) {
LOGGER.debug("Select all checkbox work only with {} provider type. Current provider is type of {}.", new Object[] { BaseSortableDataProvider.class.getName(), provider.getClass().getName() });
}
//update selected flag in model dto objects based on select all header state
BaseSortableDataProvider baseProvider = (BaseSortableDataProvider) provider;
List<T> objects = baseProvider.getAvailableData();
for (T object : objects) {
if (object instanceof Selectable) {
Selectable selectable = (Selectable) object;
selectable.setSelected(selected);
}
}
//refresh rows with ajax
ComponentHierarchyIterator iterator = table.visitChildren(SelectableDataTable.SelectableRowItem.class);
while (iterator.hasNext()) {
SelectableDataTable.SelectableRowItem row = (SelectableDataTable.SelectableRowItem) iterator.next();
if (!row.getOutputMarkupId()) {
//we skip rows that doesn't have outputMarkupId set to true (it would fail)
continue;
}
target.add(row);
}
}
use of org.apache.wicket.util.iterator.ComponentHierarchyIterator in project midpoint by Evolveum.
the class CheckBoxHeaderColumn method findCheckBoxColumnHeader.
public static CheckBoxPanel findCheckBoxColumnHeader(DataTable table) {
WebMarkupContainer topToolbars = table.getTopToolbars();
ComponentHierarchyIterator iterator = topToolbars.visitChildren(TableHeadersToolbar.class);
if (!iterator.hasNext()) {
return null;
}
TableHeadersToolbar toolbar = (TableHeadersToolbar) iterator.next();
// simple attempt to find checkbox which is header for our column
// todo: this search will fail if there are more checkbox header columns (which is not supported now,
// because Selectable.F_SELECTED is hardcoded all over the place...
iterator = toolbar.visitChildren(CheckBoxPanel.class);
while (iterator.hasNext()) {
Component c = iterator.next();
if (!c.getOutputMarkupId()) {
continue;
}
return (CheckBoxPanel) c;
}
return null;
}
Aggregations