use of com.google.gwt.safehtml.shared.SafeHtml 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 com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.
the class VmSnapshotCreatePopupWidget method updateMemoryWarning.
private void updateMemoryWarning(SnapshotModel model) {
Collection<DiskImage> diskImages = model.getSnapshotDisks().getItems();
List<DiskImage> selectedDiskImages = model.getSnapshotDisks().getSelectedItems();
boolean partialDisksSelection = selectedDiskImages != null && diskImages.size() != selectedDiskImages.size();
boolean includeMemory = model.getMemory().getEntity();
SafeHtml warningImage = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.logWarningImage()).getHTML());
HTML partialSnapshotWithMemoryWarningWidget = new HTML(templates.iconWithText(warningImage, constants.snapshotCreationWithMemoryAndPartialDisksWarning()));
HTML memoryWarningWidget = new HTML(templates.iconWithText(warningImage, constants.snapshotCreationWithMemoryNotLiveWarning()));
warningPanel.clear();
// Show warning in case of saving memory to snapshot and excluding some disks.
if (includeMemory && partialDisksSelection) {
warningPanel.add(partialSnapshotWithMemoryWarningWidget);
}
// Show warning in case of saving memory since it is not really 'live'
if (includeMemory) {
warningPanel.add(memoryWarningWidget);
}
}
use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.
the class ImportVmFromExternalProviderPopupView method initMainTable.
protected void initMainTable() {
this.table = new ListModelObjectCellTable<>();
AbstractCheckboxColumn<ImportVmData> cloneVMColumn = new AbstractCheckboxColumn<ImportVmData>((index, model, value) -> {
model.getClone().setEntity(value);
table.asEditor().edit(importModel);
}) {
@Override
public Boolean getValue(ImportVmData model) {
return model.getClone().getEntity();
}
@Override
protected boolean canEdit(ImportVmData model) {
return model.getClone().getIsChangable();
}
@Override
protected String getDisabledMessage(ImportVmData model) {
return model.getClone().getChangeProhibitionReason();
}
};
// $NON-NLS-1$
table.addColumn(cloneVMColumn, constants.cloneVM(), "50px");
AbstractTextColumn<ImportVmData> nameColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return object.getName();
}
};
// $NON-NLS-1$
table.addColumn(nameColumn, constants.nameVm(), "150px");
AbstractTextColumn<ImportVmData> originColumn = new AbstractEnumColumn<ImportVmData, OriginType>() {
@Override
protected OriginType getRawValue(ImportVmData object) {
return object.getVm().getOrigin();
}
};
// $NON-NLS-1$
table.addColumn(originColumn, constants.originVm(), "100px");
table.addColumn(new AbstractSafeHtmlColumn<ImportVmData>() {
@Override
public SafeHtml getValue(ImportVmData object) {
return VmTypeColumn.getRenderedValue(object.getVm());
}
}, constants.empty(), // $NON-NLS-1$
"30px");
AbstractTextColumn<ImportVmData> memoryColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return messages.megabytes(String.valueOf(object.getVm().getVmMemSizeMb()));
}
};
// $NON-NLS-1$
table.addColumn(memoryColumn, constants.memoryVm(), "100px");
AbstractTextColumn<ImportVmData> cpuColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return String.valueOf(object.getVm().getNumOfCpus());
}
};
// $NON-NLS-1$
table.addColumn(cpuColumn, constants.cpusVm(), "50px");
AbstractTextColumn<ImportVmData> archColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return String.valueOf(object.getVm().getClusterArch());
}
};
// $NON-NLS-1$
table.addColumn(archColumn, constants.architectureVm(), "50px");
AbstractTextColumn<ImportVmData> diskColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return String.valueOf(object.getVm().getDiskMap().size());
}
};
// $NON-NLS-1$
table.addColumn(diskColumn, constants.disksVm(), "50px");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
splitLayoutPanel.add(sp);
table.getElement().getStyle().setPosition(Position.RELATIVE);
}
use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.
the class SubTabClusterNetworkView method createNetRoleColumn.
private AbstractSafeHtmlColumn<Network> createNetRoleColumn() {
return new AbstractSafeHtmlColumn<Network>() {
@Override
public SafeHtml getValue(Network network) {
List<SafeHtml> images = new LinkedList<>();
final NetworkCluster networkCluster = network.getCluster();
if (networkCluster != null) {
images.add(thisOrEmptyImage(networkCluster.isManagement(), managementImage));
images.add(thisOrEmptyImage(networkCluster.isDisplay(), displayImage));
images.add(thisOrEmptyImage(networkCluster.isMigration(), migrationImage));
images.add(thisOrEmptyImage(network.getCluster().isGluster(), glusterNwImage));
images.add(thisOrEmptyImage(networkCluster.isDefaultRoute(), defaultRouteImage));
}
return MultiImageColumnHelper.getValue(images);
}
@Override
public SafeHtml getTooltip(Network network) {
Map<SafeHtml, String> imagesToText = new LinkedHashMap<>();
final NetworkCluster networkCluster = network.getCluster();
if (networkCluster != null) {
if (networkCluster.isManagement()) {
imagesToText.put(managementImage, constants.managementItemInfo());
}
if (networkCluster.isDisplay()) {
imagesToText.put(displayImage, constants.displayItemInfo());
}
if (networkCluster.isMigration()) {
imagesToText.put(migrationImage, constants.migrationItemInfo());
}
if (network.getCluster().isGluster()) {
imagesToText.put(glusterNwImage, constants.glusterNwItemInfo());
}
if (networkCluster.isDefaultRoute()) {
imagesToText.put(defaultRouteImage, constants.defaultRouteItemInfo());
}
}
return MultiImageColumnHelper.getTooltip(imagesToText);
}
};
}
use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.
the class HostStatusCell method render.
@Override
public void render(Context context, VDS vds, SafeHtmlBuilder sb, String id) {
// Nothing to render if no host is provided:
if (vds == null) {
return;
}
// Find the image corresponding to the status of the host:
VDSStatus status = vds.getStatus();
ImageResource statusImage;
switch(status) {
case Unassigned:
case NonResponsive:
case InstallFailed:
case Connecting:
case Down:
statusImage = resources.downImage();
break;
case PreparingForMaintenance:
statusImage = resources.prepareImage();
break;
case Maintenance:
statusImage = resources.maintenanceImage();
break;
case Up:
statusImage = resources.upImage();
break;
case Error:
statusImage = resources.errorImage();
break;
case Installing:
statusImage = resources.hostInstallingImage();
break;
case Reboot:
statusImage = resources.waitImage();
break;
case NonOperational:
statusImage = resources.nonOperationalImage();
break;
case PendingApproval:
case InstallingOS:
statusImage = resources.unconfiguredImage();
break;
case Initializing:
statusImage = resources.waitImage();
break;
case Kdumping:
statusImage = resources.waitImage();
break;
default:
statusImage = resources.downImage();
}
// Find the image corresponding to the alert:
ImageResource alertImage = resources.alertImage();
// Generate the HTML for the images:
SafeHtml statusImageHtml = AbstractImagePrototype.create(statusImage).getSafeHtml();
SafeHtml alertImageHtml = AbstractImagePrototype.create(alertImage).getSafeHtml();
// Generate the HTML for the cell, wrapped inside <div> element:
// $NON-NLS-1$ //$NON-NLS-2$
sb.appendHtmlConstant("<div id=\"" + id + "\" style=\"text-align: center;\">");
// Append status image:
sb.append(statusImageHtml);
// - host reinstall is required
if (hasPMAlert(vds) || hasNetconfigDirty(vds) || hasGlusterAlert(vds) || vds.getStaticData().isReinstallRequired() || hasDefaultRouteAlert(vds)) {
sb.append(alertImageHtml);
}
// $NON-NLS-1$
sb.appendHtmlConstant("</div>");
}
Aggregations