Search in sources :

Example 36 with QuotaCluster

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));
}
Also used : NullableButtonCell(org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell) QuotaUtilizationStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.QuotaUtilizationStatusColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) CheckboxCell(org.ovirt.engine.ui.common.widget.table.cell.CheckboxCell)

Aggregations

QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)36 Quota (org.ovirt.engine.core.common.businessentities.Quota)17 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)14 Test (org.junit.Test)12 Guid (org.ovirt.engine.core.compat.Guid)8 ArrayList (java.util.ArrayList)5 ActionType (org.ovirt.engine.core.common.action.ActionType)3 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)3 Inject (com.google.inject.Inject)2 HashMap (java.util.HashMap)2 List (java.util.List)2 QuotaClusterLimit (org.ovirt.engine.api.model.QuotaClusterLimit)2 QuotaClusterLimits (org.ovirt.engine.api.model.QuotaClusterLimits)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 IdParameters (org.ovirt.engine.core.common.action.IdParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)2 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)2