Search in sources :

Example 1 with QuotaUtilizationStatusColumn

use of org.ovirt.engine.ui.webadmin.widget.table.column.QuotaUtilizationStatusColumn 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)

Example 2 with QuotaUtilizationStatusColumn

use of org.ovirt.engine.ui.webadmin.widget.table.column.QuotaUtilizationStatusColumn in project ovirt-engine by oVirt.

the class QuotaPopupView method initQuotaStorageTable.

private void initQuotaStorageTable() {
    quotaStorageTable = new ListModelObjectCellTable<>();
    storageQuotaTableContainer.add(quotaStorageTable);
    isStorageInQuotaColumn = new Column<QuotaStorage, Boolean>(new CheckboxCell(true, true)) {

        @Override
        public Boolean getValue(QuotaStorage object) {
            if (selectedStorageGuid.contains(object.getStorageId()) || object.getStorageSizeGB() != null) {
                if (!selectedStorageGuid.contains(object.getStorageId())) {
                    selectedStorageGuid.add(object.getStorageId());
                }
                return true;
            }
            return false;
        }
    };
    isStorageInQuotaColumn.setFieldUpdater((index, object, value) -> {
        if (value) {
            selectedStorageGuid.add(object.getStorageId());
            object.setStorageSizeGB(QuotaStorage.UNLIMITED);
        } else {
            selectedStorageGuid.remove(object.getStorageId());
            object.setStorageSizeGB(null);
        }
        if (model.getGlobalStorageQuota().getEntity()) {
            quotaStorageTable.asEditor().edit(model.getQuotaStorages());
        } else {
            quotaStorageTable.asEditor().edit(model.getAllDataCenterStorages());
        }
    });
    quotaStorageTable.addColumn(new AbstractTextColumn<QuotaStorage>() {

        @Override
        public String getValue(QuotaStorage object) {
            if (object.getStorageName() == null || object.getStorageName().length() == 0) {
                return constants.utlQuotaAllStoragesQuotaPopup();
            }
            return object.getStorageName();
        }
    }, constants.storageNameQuota(), // $NON-NLS-1$
    "200px");
    // $NON-NLS-1$
    quotaStorageTable.addColumn(new QuotaUtilizationStatusColumn<QuotaStorage>(), constants.empty(), "1px");
    quotaStorageTable.addColumn(new AbstractTextColumn<QuotaStorage>() {

        @Override
        public String getValue(QuotaStorage object) {
            if (object.getStorageSizeGB() == null) {
                // $NON-NLS-1$
                return "";
            } else if (object.getStorageSizeGB().equals(QuotaStorage.UNLIMITED)) {
                return messages.unlimitedStorageConsumption(object.getStorageSizeGBUsage() == 0 ? // $NON-NLS-1$
                "0" : diskSizeRenderer.render(object.getStorageSizeGBUsage()));
            } else {
                return messages.limitedStorageConsumption(object.getStorageSizeGBUsage() == 0 ? // $NON-NLS-1$
                "0" : diskSizeRenderer.render(object.getStorageSizeGBUsage()), object.getStorageSizeGB());
            }
        }
    }, constants.quota());
    Column<QuotaStorage, String> editColumn = new Column<QuotaStorage, String>(new NullableButtonCell()) {

        @Override
        public String getValue(QuotaStorage object) {
            if (model.getGlobalStorageQuota().getEntity() || (model.getSpecificStorageQuota().getEntity() && selectedStorageGuid.contains(object.getStorageId()))) {
                return constants.editCellQuota();
            }
            return null;
        }
    };
    editColumn.setFieldUpdater((index, object, value) -> model.editQuotaStorage(object));
    // $NON-NLS-1$
    quotaStorageTable.addColumn(editColumn, constants.empty(), "50px");
}
Also used : NullableButtonCell(org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) 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) CheckboxCell(org.ovirt.engine.ui.common.widget.table.cell.CheckboxCell)

Aggregations

Column (com.google.gwt.user.cellview.client.Column)2 CheckboxCell (org.ovirt.engine.ui.common.widget.table.cell.CheckboxCell)2 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)2 NullableButtonCell (org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell)2 QuotaUtilizationStatusColumn (org.ovirt.engine.ui.webadmin.widget.table.column.QuotaUtilizationStatusColumn)2 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)1 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)1