use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaPopupView method initQuotaClusterTable.
private void initQuotaClusterTable() {
quotaClusterTable = new ListModelObjectCellTable<>();
clusterQuotaTableContainer.add(quotaClusterTable);
isClusterInQuotaColumn = new Column<QuotaCluster, Boolean>(new CheckboxCell(true, true)) {
@Override
public Boolean getValue(QuotaCluster object) {
if (selectedClusterGuid.contains(object.getClusterId()) || (object.getMemSizeMB() != null && object.getVirtualCpu() != null)) {
if (!selectedClusterGuid.contains(object.getClusterId())) {
selectedClusterGuid.add(object.getClusterId());
}
return true;
}
return false;
}
};
isClusterInQuotaColumn.setFieldUpdater((index, object, value) -> {
if (value) {
selectedClusterGuid.add(object.getClusterId());
object.setVirtualCpu(QuotaCluster.UNLIMITED_VCPU);
object.setMemSizeMB(QuotaCluster.UNLIMITED_MEM);
} else {
selectedClusterGuid.remove(object.getClusterId());
object.setVirtualCpu(null);
object.setMemSizeMB(null);
}
if (model.getGlobalClusterQuota().getEntity()) {
quotaClusterTable.asEditor().edit(model.getQuotaClusters());
} else {
quotaClusterTable.asEditor().edit(model.getAllDataCenterClusters());
}
});
quotaClusterTable.addColumn(new AbstractTextColumn<QuotaCluster>() {
@Override
public String getValue(QuotaCluster object) {
if (object.getClusterName() == null || object.getClusterName().length() == 0) {
return constants.ultQuotaForAllClustersQuotaPopup();
}
return object.getClusterName();
}
}, constants.clusterNameQuota(), // $NON-NLS-1$
"200px");
// $NON-NLS-1$
quotaClusterTable.addColumn(new QuotaUtilizationStatusColumn<QuotaCluster>(), constants.empty(), "1px");
quotaClusterTable.addColumn(new AbstractTextColumn<QuotaCluster>() {
@Override
public String getValue(QuotaCluster object) {
if (object.getMemSizeMB() == null) {
// $NON-NLS-1$
return "";
} else if (object.getMemSizeMB().equals(QuotaCluster.UNLIMITED_MEM)) {
return messages.unlimitedMemConsumption(object.getMemSizeMBUsage());
} else {
return messages.limitedMemConsumption(object.getMemSizeMBUsage(), object.getMemSizeMB());
}
}
}, constants.quotaOfMemQuota());
quotaClusterTable.addColumn(new AbstractTextColumn<QuotaCluster>() {
@Override
public String getValue(QuotaCluster object) {
if (object.getVirtualCpu() == null) {
// $NON-NLS-1$
return "";
} else if (object.getVirtualCpu().equals(QuotaCluster.UNLIMITED_VCPU)) {
return messages.unlimitedVcpuConsumption(object.getVirtualCpuUsage());
} else {
return messages.limitedVcpuConsumption(object.getVirtualCpuUsage(), object.getVirtualCpu());
}
}
}, constants.quotaOfVcpuQuota());
NullableButtonCell editCellButton = new NullableButtonCell();
Column<QuotaCluster, String> editColumn = new Column<QuotaCluster, String>(editCellButton) {
@Override
public String getValue(QuotaCluster object) {
if (model.getGlobalClusterQuota().getEntity() || (model.getSpecificClusterQuota().getEntity() && selectedClusterGuid.contains(object.getClusterId()))) {
return constants.editCellQuota();
}
return null;
}
};
// $NON-NLS-1$
quotaClusterTable.addColumn(editColumn, constants.empty(), "50px");
editColumn.setFieldUpdater((index, object, value) -> model.editQuotaCluster(object));
}
Aggregations