Search in sources :

Example 1 with NullableButtonCell

use of org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell in project ovirt-engine by oVirt.

the class ManagePolicyUnitPopupView method initTable.

private void initTable() {
    policyUnitTable = new ListModelObjectCellTable<>();
    policyUnitTable.enableColumnResizing();
    policyUnitTableContainer.add(policyUnitTable);
    policyUnitTable.addColumn(new AbstractImageResourceColumn<PolicyUnit>() {

        @Override
        public ImageResource getValue(PolicyUnit object) {
            if (object.isInternal()) {
                return resources.lockImage();
            }
            return resources.exteranlPolicyUnitImage();
        }

        @Override
        public SafeHtml getTooltip(PolicyUnit object) {
            String tooltipContent = null;
            if (object.isInternal()) {
                tooltipContent = constants.internalPolicyUnit();
            } else {
                tooltipContent = constants.externalPolicyUnit();
            }
            return SafeHtmlUtils.fromSafeConstant(tooltipContent);
        }
    }, constants.empty(), // $NON-NLS-1$
    "20px");
    policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {

        @Override
        public String getValue(PolicyUnit object) {
            return object.getName();
        }
    }, constants.policyUnitName(), // $NON-NLS-1$
    "180px");
    policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {

        @Override
        public String getValue(PolicyUnit object) {
            return EnumTranslator.getInstance().translate(object.getPolicyUnitType());
        }
    }, constants.policyUnitType(), // $NON-NLS-1$
    "100px");
    policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {

        @Override
        public String getValue(PolicyUnit object) {
            return object.isEnabled() ? constants.enabledPolicyUnit() : constants.disabledPolicyUnit();
        }
    }, constants.policyUnitEnabledStatus(), // $NON-NLS-1$
    "75px");
    Column<PolicyUnit, String> removeButtonColumn = new Column<PolicyUnit, String>(new NullableButtonCell()) {

        @Override
        public String getValue(PolicyUnit object) {
            if (!object.isEnabled()) {
                return constants.removePolicyUnit();
            }
            return null;
        }
    };
    // $NON-NLS-1$
    policyUnitTable.addColumn(removeButtonColumn, constants.removePolicyUnit(), "80px");
    removeButtonColumn.setFieldUpdater((index, object, value) -> model.remove(object));
}
Also used : NullableButtonCell(org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Example 2 with NullableButtonCell

use of org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell 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 3 with NullableButtonCell

use of org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell 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)3 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)3 NullableButtonCell (org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell)3 CheckboxCell (org.ovirt.engine.ui.common.widget.table.cell.CheckboxCell)2 QuotaUtilizationStatusColumn (org.ovirt.engine.ui.webadmin.widget.table.column.QuotaUtilizationStatusColumn)2 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)1 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)1 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)1 AbstractImageResourceColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn)1