use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class DiskModel method diskToModel.
public static DiskModel diskToModel(Disk disk) {
DiskModel diskModel = new DiskModel();
diskModel.getAlias().setEntity(disk.getDiskAlias());
if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
DiskImage diskImage = (DiskImage) disk;
EntityModel<Integer> sizeEntity = new EntityModel<>();
sizeEntity.setEntity((int) diskImage.getSizeInGigabytes());
diskModel.setSize(sizeEntity);
ListModel<VolumeType> volumeList = new ListModel<>();
volumeList.setItems(diskImage.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Arrays.asList(new VolumeType[] { VolumeType.Preallocated })) : AsyncDataProvider.getInstance().getVolumeTypeList());
volumeList.setSelectedItem(diskImage.getVolumeType());
diskModel.setVolumeType(volumeList);
}
diskModel.setDisk(disk);
return diskModel;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class EditDiskModel method datacenter_SelectedItemChanged.
@Override
protected void datacenter_SelectedItemChanged() {
super.datacenter_SelectedItemChanged();
// this needs to be executed after the data center is loaded because the update quota needs both values
if (getDisk().getDiskStorageType() == DiskStorageType.IMAGE) {
Guid storageDomainId = ((DiskImage) getDisk()).getStorageIds().get(0);
AsyncDataProvider.getInstance().getStorageDomainById(new AsyncQuery<>(storageDomain -> getStorageDomain().setSelectedItem(storageDomain)), storageDomainId);
} else if (getDisk().getDiskStorageType() == DiskStorageType.LUN) {
LunDisk lunDisk = (LunDisk) getDisk();
getDiskStorageType().setEntity(DiskStorageType.LUN);
getSize().setEntity(lunDisk.getLun().getDeviceSize());
getSizeExtend().setIsAvailable(false);
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage 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");
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage 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");
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage 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");
}
Aggregations