use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.
the class ImportIscsiStorageView method addTargetsSelectionColumn.
private void addTargetsSelectionColumn() {
AbstractSelectAllCheckBoxHeader<SanTargetModel> selectAllHeader = new AbstractSelectAllCheckBoxHeader<SanTargetModel>() {
@Override
protected void selectionChanged(Boolean value) {
ListModel listModel = targetsTable.asEditor().flush();
if (listModel == null || listModel.getItems() == null) {
return;
}
handleSelection(value, listModel, targetsTable.getSelectionModel());
}
@Override
public void handleSelection(Boolean value, ListModel listModel, SelectionModel selectionModel) {
if (!listModel.getItems().iterator().hasNext()) {
return;
}
ArrayList<SanTargetModel> selectedItems = new ArrayList<>();
for (SanTargetModel entity : (Iterable<SanTargetModel>) listModel.getItems()) {
if (!entity.getIsLoggedIn()) {
if (value) {
selectedItems.add(entity);
}
selectionModel.setSelected(entity, value);
}
}
listModel.setSelectedItems(selectedItems);
}
@Override
public Boolean getValue() {
ListModel listModel = targetsTable.asEditor().flush();
if (listModel == null || listModel.getItems() == null) {
return false;
}
return getCheckValue(listModel.getItems(), targetsTable.getSelectionModel());
}
};
AbstractCheckboxColumn<SanTargetModel> checkColumn = new AbstractCheckboxColumn<SanTargetModel>() {
@Override
protected boolean canEdit(SanTargetModel object) {
return !object.getIsLoggedIn();
}
@Override
public Boolean getValue(SanTargetModel object) {
return targetsTable.getSelectionModel().isSelected(object) || object.getIsLoggedIn();
}
};
// $NON-NLS-1$
targetsTable.addColumn(checkColumn, selectAllHeader, "25px");
}
Aggregations