use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method initCinderDisksTable.
private void initCinderDisksTable() {
cinderDiskTable.enableColumnResizing();
AbstractTextColumn<EntityModel> aliasColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskAlias();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(aliasColumn, constants.aliasVmDiskTable(), "100px");
AbstractTextColumn<EntityModel> descriptionColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskDescription();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(descriptionColumn, constants.descriptionVmDiskTable(), "100px");
AbstractDiskSizeColumn<EntityModel> sizeColumn = new AbstractDiskSizeColumn<EntityModel>(SizeConverter.SizeUnit.GiB) {
@Override
protected Long getRawValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getSizeInGigabytes();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(sizeColumn, constants.provisionedSizeVmDiskTable(), "100px");
// $NON-NLS-1$
cinderDiskTable.addColumn(getDiskInterfaceSelectionColumn(), constants.interfaceVmDiskPopup(), "115px");
AbstractTextColumn<EntityModel> cinderVolumeTypeColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.getCinderVolumeType();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(cinderVolumeTypeColumn, constants.cinderVolumeTypeDisk(), "90px");
cinderDiskTable.addColumn(getReadOnlyCheckBoxColumn(), new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.readOnly())), // $NON-NLS-1$
"30px");
cinderDiskTable.addColumn(getBootCheckBoxColumn(), new ImageResourceHeader(resources.bootableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.bootableDisk())), // $NON-NLS-1$
"30px");
cinderDiskTable.addColumn(new AbstractImageResourceColumn<EntityModel>() {
@Override
public ImageResource getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.isShareable() ? resources.shareableDiskIcon() : null;
}
@Override
public SafeHtml getTooltip(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
if (disk.isShareable()) {
return SafeHtmlUtils.fromSafeConstant(constants.shareable());
}
return null;
}
}, new ImageResourceHeader(resources.shareableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.shareable())), // $NON-NLS-1$
"30px");
// $NON-NLS-1$
cinderDiskTable.setWidth("100%");
cinderDiskTable.setEmptyTableWidget(new NoItemsLabel());
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationView method addDiskList.
void addDiskList(DisksAllocationModel model) {
diskListPanel.clear();
diskAllocationLabel.setVisible(!model.getDisks().isEmpty());
int diskIndex = 0;
String columnWidth = calculateColumnWidthPercentage();
for (final DiskModel diskModel : model.getDisks()) {
DisksAllocationItemView disksAllocationItemView = new DisksAllocationItemView(columnWidth);
disksAllocationItemView.edit(diskModel);
disksAllocationItemView.setIsAliasChangeable(model.getIsAliasChangable());
disksAllocationItemView.setElementId(// $NON-NLS-1$
ElementIdUtils.createElementId(elementId, "disk" + diskIndex++));
diskListPanel.add(disksAllocationItemView);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class AbstractDiskRemoveConfirmationPopupView method addItemText.
@Override
protected void addItemText(Object item) {
DiskModel diskModel = (DiskModel) item;
Disk disk = diskModel.getDisk();
boolean isInVm = diskModel.getVm() != null;
notes.clear();
addItemLabel(getItemTextFormatted(disk.getDiskAlias()));
if (disk.isShareable()) {
notes.add(constants.shareable());
}
if (isInVm && disk.getDiskVmElementForVm(diskModel.getVm().getId()) != null && disk.getDiskVmElementForVm(diskModel.getVm().getId()).isBoot()) {
notes.add(constants.bootable());
}
if (isInVm && disk.getNumberOfVms() > 1) {
notes.add(messages.diskAttachedToOtherVMs(disk.getNumberOfVms() - 1, disk.getVmNames().get(0)));
} else if (!isInVm && disk.getNumberOfVms() > 0) {
notes.add(messages.diskAttachedToVMs(disk.getNumberOfVms()));
}
if (disk.getContentType() == DiskContentType.MEMORY_METADATA_VOLUME || disk.getContentType() == DiskContentType.MEMORY_DUMP_VOLUME) {
notes.add(constants.memoryDisk());
}
if (!notes.isEmpty()) {
String notes = constants.htmlTab() + messages.diskNote() + getFormattedNote();
// $NON-NLS-1$ //$NON-NLS-2$
addItemLabel(SafeHtmlUtils.fromSafeConstant("<b>" + notes + "</b>"));
}
addItemLabel(SafeHtmlUtils.fromSafeConstant(constants.lineBreak()));
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class MoveOrCopyDiskModel method validate.
public boolean validate() {
boolean quotaValidated = true;
if (getQuotaEnforcementType() == QuotaEnforcementTypeEnum.DISABLED || getQuotaEnforcementType() == QuotaEnforcementTypeEnum.SOFT_ENFORCEMENT) {
quotaValidated = false;
}
boolean isValid = true;
for (DiskModel diskModel : getDisks()) {
if (quotaValidated) {
diskModel.getQuota().validateSelectedItem(new IValidation[] { new SelectedQuotaValidation() });
isValid &= diskModel.getQuota().getIsValid();
}
diskModel.getAlias().validateEntity(new IValidation[] { new NotEmptyValidation(), new I18NNameValidation() });
isValid &= diskModel.getAlias().getIsValid();
}
return isValid;
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class MoveOrCopyDiskModel method postInitStorageDomains.
protected void postInitStorageDomains() {
for (DiskModel disk : getDisks()) {
DiskImage diskImage = (DiskImage) disk.getDisk();
// Source storage domains
List<Guid> diskStorageIds = diskImage.getStorageIds();
List<StorageDomain> sourceStorageDomains = Linq.getStorageDomainsByIds(diskStorageIds, getActiveStorageDomains());
boolean isDiskBasedOnTemplate = !diskImage.getParentId().equals(Guid.Empty);
ArrayList<StorageDomain> destStorageDomains = getDestinationDomains(getActiveStorageDomains(), sourceStorageDomains, disk, isDiskBasedOnTemplate);
// Add prohibition reasons
if (sourceStorageDomains.isEmpty() || destStorageDomains.isEmpty()) {
problematicDisks.add(disk.getAlias().getEntity());
updateChangeability(disk, isDiskBasedOnTemplate, sourceStorageDomains.isEmpty(), destStorageDomains.isEmpty());
}
// Sort and add storage domains
Collections.sort(destStorageDomains, new NameableComparator());
Collections.sort(sourceStorageDomains, new NameableComparator());
disk.getStorageDomain().setItems(destStorageDomains);
disk.getSourceStorageDomain().setItems(sourceStorageDomains);
addSourceStorageDomainName(disk, sourceStorageDomains);
}
sortDisks();
postCopyOrMoveInit();
}
Aggregations