use of org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader in project ovirt-engine by oVirt.
the class SubTabTemplateDiskView method initHeader.
@Override
protected void initHeader() {
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.aliasDisk(), "");
ImageResourceHeader readOnlyColumnHeader = new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromSafeConstant(constants.readOnly()));
// $NON-NLS-1$);
table.addColumn(new EmptyColumn(), readOnlyColumnHeader, "60px");
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.provisionedSizeDisk(), "120px");
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.sizeDisk(), "120px");
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.statusDisk(), "120px");
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.allocationDisk(), "120px");
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.interfaceDisk(), "120px");
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.typeDisk(), "120px");
// $NON-NLS-1$
table.addColumn(new EmptyColumn(), constants.creationDateDisk(), "150px");
// $NON-NLS-1$
table.setHeight("30px");
}
use of org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method initDiskImagesTable.
private void initDiskImagesTable() {
imageDiskTable.enableColumnResizing();
AbstractTextColumn<EntityModel> aliasColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getDiskAlias();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(aliasColumn, constants.aliasVmDiskTable(), "85px");
AbstractTextColumn<EntityModel> descriptionColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getDiskDescription();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(descriptionColumn, constants.descriptionVmDiskTable(), "85px");
AbstractTextColumn<EntityModel> idColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getId().toString();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(idColumn, constants.idVmDiskTable(), "85px");
AbstractDiskSizeColumn<EntityModel> sizeColumn = new AbstractDiskSizeColumn<EntityModel>() {
@Override
protected Long getRawValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getSize();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(sizeColumn, constants.provisionedSizeVmDiskTable(), "100px");
AbstractDiskSizeColumn<EntityModel> actualSizeColumn = new AbstractDiskSizeColumn<EntityModel>() {
@Override
protected Long getRawValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getActualSizeInBytes();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(actualSizeColumn, constants.sizeVmDiskTable(), "100px");
AbstractTextColumn<EntityModel> storageDomainColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getStoragesNames().get(0);
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(storageDomainColumn, constants.storageDomainVmDiskTable(), "100px");
// $NON-NLS-1$
imageDiskTable.addColumn(getDiskInterfaceSelectionColumn(), constants.interfaceVmDiskPopup(), "115px");
imageDiskTable.addColumn(getReadOnlyCheckBoxColumn(), new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.readOnly())), // $NON-NLS-1$
"30px");
imageDiskTable.addColumn(getBootCheckBoxColumn(), new ImageResourceHeader(resources.bootableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.bootableDisk())), // $NON-NLS-1$
"30px");
imageDiskTable.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$
imageDiskTable.setWidth("100%");
imageDiskTable.setEmptyTableWidget(new NoItemsLabel());
}
use of org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader in project ovirt-engine by oVirt.
the class VmSnapshotCustomPreviewPopupWidget method createPreviewTable.
private void createPreviewTable() {
previewTable.addColumn(new AbstractFullDateTimeColumn<SnapshotModel>() {
@Override
protected Date getRawValue(SnapshotModel snapshotModel) {
return snapshotModel.getEntity().getCreationDate();
}
}, constants.dateSnapshot(), // $NON-NLS-1$
"140px");
previewTable.addColumn(new AbstractTextColumn<SnapshotModel>() {
@Override
public String getValue(SnapshotModel snapshotModel) {
return snapshotModel.getEntity().getDescription();
}
}, constants.descriptionSnapshot(), // $NON-NLS-1$
"100px");
previewTable.setSelectionModel(new NoSelectionModel());
Column<SnapshotModel, Boolean> vmConfColumn = new Column<SnapshotModel, Boolean>(new RadioboxCell()) {
@Override
public Boolean getValue(SnapshotModel model) {
Snapshot snapshotVmConf = model.getEntity();
Snapshot toPreviewVmConf = previewSnapshotModel.getSnapshotModel().getEntity();
if (snapshotVmConf == null && toPreviewVmConf == null) {
return true;
}
return snapshotVmConf != null && snapshotVmConf.equals(toPreviewVmConf);
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
if (!snapshotModel.getEntity().isVmConfigurationBroken()) {
super.render(context, snapshotModel, sb);
} else {
sb.appendEscaped(constants.notAvailableLabel());
}
}
};
vmConfColumn.setFieldUpdater((index, snapshotModel, value) -> {
previewSnapshotModel.setSnapshotModel(snapshotModel);
previewSnapshotModel.clearMemorySelection();
updateWarnings();
refreshTable(previewTable);
if (snapshotModel.getVm() == null) {
snapshotModel.updateVmConfiguration(returnValue -> updateInfoPanel());
} else {
updateInfoPanel();
}
});
previewTable.addColumn(vmConfColumn, new ImageResourceHeader(resources.vmConfIcon(), SafeHtmlUtils.fromTrustedString(constants.vmConfiguration())), // $NON-NLS-1$
"30px");
AbstractCheckboxColumn<SnapshotModel> memoryColumn = new AbstractCheckboxColumn<SnapshotModel>((index, snapshotModel, value) -> {
previewSnapshotModel.getSnapshotModel().getMemory().setEntity(value);
refreshTable(previewTable);
updateWarnings();
}) {
@Override
public Boolean getValue(SnapshotModel snapshotModel) {
return snapshotModel.getMemory().getEntity();
}
@Override
protected boolean canEdit(SnapshotModel snapshotModel) {
boolean containsMemory = snapshotModel.getEntity().containsMemory();
SnapshotModel selectedSnapshotModel = previewSnapshotModel.getSnapshotModel();
return containsMemory && snapshotModel == selectedSnapshotModel;
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
if (snapshotModel.getEntity().containsMemory()) {
super.render(context, snapshotModel, sb);
} else {
sb.appendEscaped(constants.notAvailableLabel());
}
}
};
previewTable.addColumn(memoryColumn, templates.iconWithText(imageResourceToSafeHtml(resources.memorySmallIcon()), constants.memorySnapshot()), // $NON-NLS-1$
"100px");
AbstractCheckboxColumn<SnapshotModel> vmLeaseColumn = new AbstractCheckboxColumn<SnapshotModel>((index, snapshotModel, value) -> {
snapshotModel.getLeaseExists().setEntity(value);
refreshTable(previewTable);
updateWarnings();
}) {
@Override
public Boolean getValue(SnapshotModel model) {
if (model.getLeaseExists() != null) {
return model.getLeaseExists().getEntity();
}
return false;
}
@Override
protected boolean canEdit(SnapshotModel snapshotModel) {
// prevent from selecting more then one leases in case many snapshots have leases
if (snapshotModel.getLeaseExists() != null) {
SnapshotModel result = previewSnapshotModel.getSnapshots().getItems().stream().filter(model -> model.getEntity().getId() != snapshotModel.getEntity().getId()).filter(model -> model.getLeaseExists().getEntity() != null).filter(model -> model.getLeaseExists().getEntity()).findFirst().orElse(null);
return result == null;
}
return false;
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
if (snapshotModel.getLeaseExists().getEntity() != null) {
super.render(context, snapshotModel, sb);
} else {
sb.appendEscaped(constants.notAvailableLabel());
}
}
};
// $NON-NLS-1$
previewTable.addColumn(vmLeaseColumn, constants.leaseSnapshot(), "80px");
List<DiskImage> disks = previewSnapshotModel.getAllDisks();
Collections.sort(disks, new DiskByDiskAliasComparator());
for (final DiskImage disk : disks) {
previewTable.addColumn(new AbstractCheckboxColumn<SnapshotModel>((index, snapshotModel, value) -> {
ListModel diskListModel = previewSnapshotModel.getDiskSnapshotsMap().get(disk.getId());
DiskImage image = snapshotModel.getImageByDiskId(disk.getId());
diskListModel.setSelectedItem(Boolean.TRUE.equals(value) ? image : null);
refreshTable(previewTable);
updateWarnings();
updateInfoPanel();
}) {
@Override
public Boolean getValue(SnapshotModel snapshotModel) {
ListModel diskListModel = previewSnapshotModel.getDiskSnapshotsMap().get(disk.getId());
DiskImage image = snapshotModel.getImageByDiskId(disk.getId());
return image != null ? image.equals(diskListModel.getSelectedItem()) : false;
}
@Override
protected boolean canEdit(SnapshotModel model) {
return true;
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
DiskImage image = snapshotModel.getImageByDiskId(disk.getId());
if (image == null) {
sb.appendEscaped(constants.notAvailableLabel());
} else if (image.getImageStatus() == ImageStatus.ILLEGAL) {
sb.append(templates.text(constants.notAvailableLabel()));
} else {
super.render(context, snapshotModel, sb);
}
}
@Override
public SafeHtml getTooltip(SnapshotModel model) {
if (disk != null && disk.getId() != null) {
DiskImage image = model.getImageByDiskId(disk.getId());
if (image != null && image.getImageStatus() == ImageStatus.ILLEGAL) {
return SafeHtmlUtils.fromSafeConstant(constants.illegalStatus());
}
}
return null;
}
}, new SafeHtmlHeader(templates.iconWithText(imageResourceToSafeHtml(resources.diskIcon()), disk.getDiskAlias()), SafeHtmlUtils.fromString(disk.getId().toString())), // $NON-NLS-1$
"120px");
// Edit preview table
previewTable.asEditor().edit(previewSnapshotModel.getSnapshots());
}
previewTable.addCellPreviewHandler(new CellPreviewEvent.Handler<EntityModel>() {
long lastClick = -1000;
@Override
public void onCellPreview(CellPreviewEvent<EntityModel> event) {
NativeEvent nativeEvent = event.getNativeEvent();
long clickAt = System.currentTimeMillis();
if (BrowserEvents.CLICK.equals(nativeEvent.getType())) {
if (clickAt - lastClick < 300) {
// double click: 2 clicks detected within 300 ms
SnapshotModel selectedSnapshotModel = (SnapshotModel) event.getValue();
if (!selectedSnapshotModel.getEntity().isVmConfigurationBroken()) {
previewSnapshotModel.clearSelection(selectedSnapshotModel.getEntity().getId());
previewSnapshotModel.selectSnapshot(selectedSnapshotModel.getEntity().getId());
updateWarnings();
refreshTable(previewTable);
}
}
lastClick = System.currentTimeMillis();
}
}
});
}
use of org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader in project ovirt-engine by oVirt.
the class BaseVmDiskListModelTable method onDiskViewTypeChanged.
void onDiskViewTypeChanged(DiskStorageType diskType) {
boolean all = diskType == null;
boolean images = diskType == DiskStorageType.IMAGE;
boolean luns = diskType == DiskStorageType.LUN;
boolean cinder = diskType == DiskStorageType.CINDER;
getTable().getSelectionModel().clear();
getModel().setItems(null);
getModel().search();
getTable().ensureColumnVisible(DisksViewColumns.diskStatusColumn, constants.empty(), all || images || luns || cinder, // $NON-NLS-1$
"30px");
getTable().ensureColumnVisible(aliasColumn, constants.aliasDisk(), all || images || luns || cinder, // $NON-NLS-1$
"120px");
getTable().ensureColumnVisible(DisksViewColumns.bootableDiskColumn, new ImageResourceHeader(DisksViewColumns.bootableDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.bootableDisk())), all || images || luns || cinder, // $NON-NLS-1$
"30px");
getTable().ensureColumnVisible(shareableDiskColumn, new ImageResourceHeader(shareableDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.shareable())), all || images || luns || cinder, // $NON-NLS-1$
"30px");
getTable().ensureColumnVisible(DisksViewColumns.readOnlyDiskColumn, new ImageResourceHeader(DisksViewColumns.readOnlyDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.readOnly())), all || images || luns || cinder, // $NON-NLS-1$
"30px");
getTable().ensureColumnVisible(sizeColumn, constants.provisionedSizeDisk(), all || images || luns || cinder, // $NON-NLS-1$
"110px");
getTable().ensureColumnVisible(actualSizeColumn, constants.sizeDisk(), images, // $NON-NLS-1$
"110px");
getTable().ensureColumnVisible(allocationColumn, constants.allocationDisk(), images, // $NON-NLS-1$
"125px");
getTable().ensureColumnVisible(storageDomainsColumn, constants.storageDomainDisk(), images || cinder, // $NON-NLS-1$
"125px");
getTable().ensureColumnVisible(DisksViewColumns.storageTypeColumn, constants.storageTypeDisk(), images, // $NON-NLS-1$
"100px");
getTable().ensureColumnVisible(cinderVolumeTypeColumn, constants.cinderVolumeTypeDisk(), cinder, // $NON-NLS-1$
"80px");
getTable().ensureColumnVisible(dateCreatedColumn, constants.creationDateDisk(), images || cinder, // $NON-NLS-1$
"120px");
getTable().ensureColumnVisible(lunIdColumn, constants.lunIdSanStorage(), luns, // $NON-NLS-1$
"130px");
getTable().ensureColumnVisible(lunSerialColumn, constants.serialSanStorage(), luns, // $NON-NLS-1$
"130px");
getTable().ensureColumnVisible(lunVendorIdColumn, constants.vendorIdSanStorage(), luns, // $NON-NLS-1$
"130px");
getTable().ensureColumnVisible(lunProductIdColumn, constants.productIdSanStorage(), luns, // $NON-NLS-1$
"130px");
getTable().ensureColumnVisible(diskContainersColumn, constants.attachedToDisk(), all || images || luns || cinder, // $NON-NLS-1$
"110px");
getTable().ensureColumnVisible(interfaceColumn, constants.interfaceDisk(), all || images || luns || cinder, // $NON-NLS-1$
"100px");
getTable().ensureColumnVisible(statusColumn, constants.statusDisk(), images || cinder || all, // $NON-NLS-1$
"80px");
getTable().ensureColumnVisible(diskStorageTypeColumn, constants.typeDisk(), all, // $NON-NLS-1$
"80px");
getTable().ensureColumnVisible(descriptionColumn, constants.descriptionDisk(), all || images || luns, // $NON-NLS-1$
"90px");
}
use of org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader in project ovirt-engine by oVirt.
the class SubTabStorageDiskView method initTable.
void initTable(StorageDomain storageDomain) {
if (storageDomain == null) {
return;
}
boolean isDataStorage = storageDomain.getStorageDomainType().isDataDomain();
boolean isCinderStorage = storageDomain.getStorageType().isCinderDomain();
getTable().enableColumnResizing();
// $NON-NLS-1$
getTable().ensureColumnVisible(aliasColumn, constants.aliasDisk(), true, "90px");
getTable().ensureColumnVisible(DisksViewColumns.bootableDiskColumn, new ImageResourceHeader(DisksViewColumns.bootableDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.bootableDisk())), true, // $NON-NLS-1$
"30px");
getTable().ensureColumnVisible(shareableDiskColumn, new ImageResourceHeader(shareableDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.shareable())), true, // $NON-NLS-1$
"30px");
// $NON-NLS-1$
getTable().ensureColumnVisible(sizeColumn, constants.provisionedSizeDisk(), true, "100px");
// $NON-NLS-1$
getTable().ensureColumnVisible(actualSizeColumn, constants.sizeDisk(), isDataStorage, "130px");
// $NON-NLS-1$
getTable().ensureColumnVisible(allocationColumn, constants.allocationDisk(), isDataStorage, "130px");
getTable().ensureColumnVisible(storageDomainsColumn, constants.storageDomainDisk(), true, // $NON-NLS-1$
"170px");
getTable().ensureColumnVisible(cinderVolumeTypeColumn, constants.cinderVolumeTypeDisk(), isCinderStorage, // $NON-NLS-1$
"90px");
// $NON-NLS-1$
getTable().ensureColumnVisible(dateCreatedColumn, constants.creationDateDisk(), true, "150px");
getTable().ensureColumnVisible(DisksViewColumns.diskContainersIconColumn, "", true, // $NON-NLS-1$ //$NON-NLS-2$
"30px");
getTable().ensureColumnVisible(diskContainersColumn, constants.attachedToDisk(), true, // $NON-NLS-1$
"120px");
// $NON-NLS-1$
getTable().ensureColumnVisible(statusColumn, constants.statusDisk(), true, "100px");
// $NON-NLS-1$
getTable().ensureColumnVisible(typeColumn, constants.typeDisk(), true, "80px");
// $NON-NLS-1$
getTable().ensureColumnVisible(descriptionColumn, constants.descriptionDisk(), true, "100px");
}
Aggregations