use of org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkClusterModel in project ovirt-engine by oVirt.
the class AbstractNetworkPopupView method initEntityModelCellTable.
void initEntityModelCellTable() {
AbstractCheckboxHeader assignAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (networkClusterModel.getIsChangable()) {
networkClusterModel.setAttached(value);
networkClusterModel.setRequired(value && networkClusterModel.isRequired());
}
}
refreshClustersTable();
}
@Override
public Boolean getValue() {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (networkClusterModel.getIsChangable() && !networkClusterModel.isAttached()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (networkClusterModel.getIsChangable()) {
return true;
}
}
return false;
}
@Override
public String getLabel() {
return constants.attachAll();
}
};
AbstractCheckboxHeader requiredAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
networkClusterModel.setRequired(value && networkClusterModel.isAttached());
}
refreshClustersTable();
}
@Override
public Boolean getValue() {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (!networkClusterModel.isRequired()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
return isRequiredChangeable();
}
@Override
public String getLabel() {
return constants.requiredAll();
}
};
clustersTable.addColumn(new AbstractTextColumn<NetworkClusterModel>() {
@Override
public String getValue(NetworkClusterModel model) {
return model.getName();
}
}, constants.nameClusterHeader());
clustersTable.addColumn(new AbstractCheckboxColumn<NetworkClusterModel>((index, model, value) -> {
model.setAttached(value);
model.setRequired(value && model.isRequired());
refreshClustersTable();
}) {
@Override
public Boolean getValue(NetworkClusterModel model) {
return model.isAttached();
}
@Override
protected boolean canEdit(NetworkClusterModel model) {
return model.getIsChangable();
}
@Override
public void render(Context context, NetworkClusterModel object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
sb.append(templates.textForCheckBox(constants.attach()));
}
}, assignAllHeader, // $NON-NLS-1$
"150px");
clustersTable.addColumn(new AbstractCheckboxColumn<NetworkClusterModel>((index, model, value) -> {
model.setRequired(value && model.isAttached());
refreshClustersTable();
}) {
@Override
public Boolean getValue(NetworkClusterModel model) {
return model.isRequired();
}
@Override
protected boolean canEdit(NetworkClusterModel model) {
return isRequiredChangeable() && model.isAttached();
}
@Override
public void render(Context context, NetworkClusterModel object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
sb.append(templates.textForCheckBox(constants.required()));
}
}, requiredAllHeader, // $NON-NLS-1$
"150px");
}
Aggregations