Search in sources :

Example 1 with CustomSelectionCell

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

the class ImportVmFromExportDomainPopupView method addAllocationColumn.

protected void addAllocationColumn() {
    ArrayList<String> allocationTypes = new ArrayList<>();
    allocationTypes.add(constants.thinAllocation());
    allocationTypes.add(constants.preallocatedAllocation());
    customSelectionCellFormatType = new CustomSelectionCell(allocationTypes);
    customSelectionCellFormatType.setStyle(EMPTY_STYLE);
    AbstractColumn<DiskImage, String> allocationColumn = new AbstractColumn<DiskImage, String>(customSelectionCellFormatType) {

        @Override
        public String getValue(DiskImage disk) {
            ImportDiskData importData = importModel.getDiskImportData(disk.getId());
            if (importData == null) {
                return "";
            }
            return new EnumRenderer<VolumeType>().render(VolumeType.forValue(importData.getSelectedVolumeType().getValue()));
        }

        @Override
        public SafeHtml getTooltip(DiskImage object) {
            return SafeHtmlUtils.fromSafeConstant(constants.importAllocationModifiedCollapse());
        }
    };
    allocationColumn.setFieldUpdater((index, disk, value) -> {
        VolumeType tempVolumeType = VolumeType.Sparse;
        if (value.equals(constants.thinAllocation())) {
            tempVolumeType = VolumeType.Sparse;
        } else if (value.equals(constants.preallocatedAllocation())) {
            tempVolumeType = VolumeType.Preallocated;
        }
        ImportDiskData importData = importModel.getDiskImportData(disk.getId());
        if (importData != null) {
            importData.setSelectedVolumeType(tempVolumeType);
        }
    });
    // $NON-NLS-1$
    diskTable.addColumn(allocationColumn, constants.allocationDisk(), "150px");
}
Also used : VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) ArrayList(java.util.ArrayList) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) ImportDiskData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportDiskData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with CustomSelectionCell

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

the class ImportVmFromExportDomainPopupView method addStorageQuotaColumn.

private void addStorageQuotaColumn() {
    if (!importModel.isQuotaEnabled()) {
        return;
    }
    if (quotaColumn != null) {
        return;
    }
    CustomSelectionCell customSelectionCellQuota = new CustomSelectionCell(new ArrayList<String>());
    customSelectionCellQuota.setStyle(EMPTY_STYLE);
    quotaColumn = new Column<DiskImage, String>(customSelectionCellQuota) {

        @Override
        public String getValue(DiskImage disk) {
            ImportDiskData importData = importModel.getDiskImportData(disk.getId());
            ArrayList<String> storageQuotaList = new ArrayList<>();
            Quota selectedQuota = null;
            if (importData != null && importData.getQuotaList() != null) {
                for (Quota quota : importData.getQuotaList()) {
                    storageQuotaList.add(quota.getQuotaName());
                    if (importData.getSelectedQuota() != null) {
                        if (quota.getId().equals(importData.getSelectedQuota().getId())) {
                            selectedQuota = quota;
                        }
                    }
                }
            }
            ((CustomSelectionCell) getCell()).setOptions(storageQuotaList);
            if (!storageQuotaList.isEmpty()) {
                if (selectedQuota != null) {
                    return selectedQuota.getQuotaName();
                } else {
                    return storageQuotaList.get(0);
                }
            }
            return "";
        }
    };
    quotaColumn.setFieldUpdater((index, disk, value) -> importModel.getDiskImportData(disk.getId()).setSelectedQuotaString(value));
    // $NON-NLS-1$
    diskTable.addColumn(quotaColumn, constants.quota(), "100px");
}
Also used : CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) ImportDiskData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportDiskData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 3 with CustomSelectionCell

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

the class ImportVmFromExportDomainPopupView method addStorageDomainsColumn.

private void addStorageDomainsColumn() {
    CustomSelectionCell customSelectionCellStorageDomain = new CustomSelectionCell(new ArrayList<String>());
    customSelectionCellStorageDomain.setStyle(EMPTY_STYLE);
    Column<DiskImage, String> storageDomainsColumn = new Column<DiskImage, String>(customSelectionCellStorageDomain) {

        @Override
        public String getValue(DiskImage disk) {
            ImportDiskData importData = importModel.getDiskImportData(disk.getId());
            ArrayList<String> storageDomainsNameList = new ArrayList<>();
            StorageDomain selectedStorageDomain = null;
            if (importData != null && importData.getStorageDomains() != null) {
                for (StorageDomain storageDomain : importData.getStorageDomains()) {
                    storageDomainsNameList.add(new StorageDomainFreeSpaceRenderer<>().render(storageDomain));
                    if (importData.getSelectedStorageDomain() != null) {
                        if (storageDomain.getId().equals(importData.getSelectedStorageDomain().getId())) {
                            selectedStorageDomain = storageDomain;
                        }
                    }
                }
            }
            ((CustomSelectionCell) getCell()).setOptions(storageDomainsNameList);
            if (!storageDomainsNameList.isEmpty()) {
                if (selectedStorageDomain != null) {
                    return new StorageDomainFreeSpaceRenderer<>().render(selectedStorageDomain);
                } else {
                    return storageDomainsNameList.get(0);
                }
            }
            return "";
        }
    };
    storageDomainsColumn.setFieldUpdater((index, disk, value) -> {
        // $NON-NLS-1$
        String storageDomainName = value.substring(0, value.lastIndexOf(" ("));
        importModel.getDiskImportData(disk.getId()).setSelectedStorageDomainString(storageDomainName);
        diskTable.asEditor().edit(importModel.getImportDiskListModel());
    });
    // $NON-NLS-1$
    diskTable.addColumn(storageDomainsColumn, constants.storageDomainDisk(), "180px");
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractFullDateTimeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList) ImportDiskData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportDiskData) StorageDomainFreeSpaceRenderer(org.ovirt.engine.ui.common.widget.renderer.StorageDomainFreeSpaceRenderer) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 4 with CustomSelectionCell

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

the class RegisterEntityInfoPanel method getDiskQuotaColumn.

private Column<Disk, String> getDiskQuotaColumn() {
    CustomSelectionCell customSelectionCell = new CustomSelectionCell(new ArrayList<String>());
    // $NON-NLS-1$
    customSelectionCell.setStyle("input-group col-xs-11");
    AbstractColumn<Disk, String> column = new AbstractColumn<Disk, String>(customSelectionCell) {

        @Override
        public String getValue(Disk disk) {
            if (disk.getDiskStorageType() == DiskStorageType.LUN) {
                return null;
            }
            List<Quota> quotas = (List<Quota>) registerEntityModel.getStorageQuota().getItems();
            if (quotas == null || quotas.isEmpty()) {
                return constants.empty();
            }
            Map<Guid, Quota> diskQuotaMap = registerEntityModel.getDiskQuotaMap().getEntity();
            if (diskQuotaMap.get(disk.getId()) == null) {
                diskQuotaMap.put(disk.getId(), quotas.get(0));
                ((CustomSelectionCell) getCell()).setOptions(registerEntityModel.getQuotaNames(quotas));
            }
            return diskQuotaMap.get(disk.getId()).getQuotaName();
        }
    };
    column.setFieldUpdater((index, disk, value) -> {
        Quota quota = registerEntityModel.getQuotaByName(value, (List<Quota>) registerEntityModel.getStorageQuota().getItems());
        registerEntityModel.getDiskQuotaMap().getEntity().put(disk.getId(), quota);
    });
    return column;
}
Also used : CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 5 with CustomSelectionCell

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

the class RegisterEntityPopupView method getClusterQuotaColumn.

protected Column<D, String> getClusterQuotaColumn() {
    CustomSelectionCell customSelectionCell = new CustomSelectionCell(new ArrayList<String>());
    // $NON-NLS-1$
    customSelectionCell.setStyle("input-group col-xs-11 gwt-ListBox");
    Column<D, String> column = new Column<D, String>(customSelectionCell) {

        @Override
        public String getValue(D object) {
            Guid clusterId = object.getCluster().getSelectedItem() != null ? object.getCluster().getSelectedItem().getId() : null;
            List<Quota> quotas = registerEntityModel.getClusterQuotasMap().getEntity().get(clusterId);
            object.getClusterQuota().setItems(quotas);
            ((CustomSelectionCell) getCell()).setOptions(registerEntityModel.getQuotaNames(quotas));
            return object.getClusterQuota().getSelectedItem() != null ? object.getClusterQuota().getSelectedItem().getQuotaName() : constants.empty();
        }
    };
    column.setFieldUpdater((index, object, value) -> registerEntityModel.selectQuotaByName(value, object.getClusterQuota()));
    return column;
}
Also used : CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) Quota(org.ovirt.engine.core.common.businessentities.Quota) Column(com.google.gwt.user.cellview.client.Column) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

CustomSelectionCell (org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell)8 ArrayList (java.util.ArrayList)6 Column (com.google.gwt.user.cellview.client.Column)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)3 AbstractColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractColumn)3 AbstractDiskSizeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn)3 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)3 AbstractImageResourceColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn)3 AbstractSafeHtmlColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn)3 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)3 ImportDiskData (org.ovirt.engine.ui.uicommonweb.models.vms.ImportDiskData)3 VmTypeColumn (org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn)3 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)2 Guid (org.ovirt.engine.core.compat.Guid)2 ImportNetworkData (org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData)2 List (java.util.List)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 VnicProfileView (org.ovirt.engine.core.common.businessentities.network.VnicProfileView)1