use of com.evolveum.midpoint.web.component.data.BaseSortableDataProvider in project midpoint by Evolveum.
the class MultipleAssignmentSelector method getListDataProvider.
public <T extends FocusType> BaseSortableDataProvider getListDataProvider(final FocusType focus) {
BaseSortableDataProvider provider;
provider = new ListDataProvider<AssignmentEditorDto>(this, new IModel<List<AssignmentEditorDto>>() {
@Override
public List<AssignmentEditorDto> getObject() {
return getAvailableAssignmentsDataList(focus);
}
@Override
public void setObject(List<AssignmentEditorDto> list) {
}
@Override
public void detach() {
}
});
return provider;
}
use of com.evolveum.midpoint.web.component.data.BaseSortableDataProvider in project midpoint by Evolveum.
the class WebComponentUtil method getSelectedData.
public static <T extends Selectable> List<T> getSelectedData(Table table) {
DataTable dataTable = table.getDataTable();
BaseSortableDataProvider<T> provider = (BaseSortableDataProvider<T>) dataTable.getDataProvider();
List<T> selected = new ArrayList<T>();
for (T bean : provider.getAvailableData()) {
if (bean.isSelected()) {
selected.add(bean);
}
}
return selected;
}
use of com.evolveum.midpoint.web.component.data.BaseSortableDataProvider in project midpoint by Evolveum.
the class PageConnectorHosts method deleteHostConfirmedPerformed.
private void deleteHostConfirmedPerformed(AjaxRequestTarget target) {
Table hostTable = getConnectorHostTable();
List<SelectableBean<ConnectorHostType>> selected = WebComponentUtil.getSelectedData(hostTable);
OperationResult result = new OperationResult(OPERATION_DELETE_HOSTS);
for (SelectableBean<ConnectorHostType> selectable : selected) {
try {
Task task = createSimpleTask(OPERATION_DELETE_HOSTS);
if (selectable.getValue() != null) {
ObjectDelta<ConnectorHostType> delta = ObjectDelta.createDeleteDelta(ConnectorHostType.class, selectable.getValue().getOid(), getPrismContext());
getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
}
} catch (Exception ex) {
result.recordPartialError("Couldn't delete host.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete host", ex);
}
}
result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "The resource(s) have been successfully deleted.");
}
BaseSortableDataProvider provider = (BaseSortableDataProvider) hostTable.getDataTable().getDataProvider();
provider.clearCache();
showResult(result);
target.add(getFeedbackPanel(), (Component) hostTable);
}
use of com.evolveum.midpoint.web.component.data.BaseSortableDataProvider 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 com.evolveum.midpoint.web.component.data.BaseSortableDataProvider in project midpoint by Evolveum.
the class CheckBoxHeaderColumn method shouldBeHeaderSelected.
public static <T> boolean shouldBeHeaderSelected(DataTable table) {
boolean selectedAll = true;
BaseSortableDataProvider baseProvider = (BaseSortableDataProvider) table.getDataProvider();
List<T> objects = baseProvider.getAvailableData();
if (objects == null || objects.isEmpty()) {
return false;
}
for (T object : objects) {
if (object instanceof Selectable) {
Selectable selectable = (Selectable) object;
selectedAll &= selectable.isSelected();
}
}
return selectedAll;
}
Aggregations