Search in sources :

Example 41 with SafeHtml

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());
}
Also used : NoItemsLabel(org.ovirt.engine.ui.common.widget.label.NoItemsLabel) ImageResourceHeader(org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AttachDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 42 with SafeHtml

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);
    }
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) HTML(com.google.gwt.user.client.ui.HTML) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 43 with SafeHtml

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);
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ImportVmData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 44 with SafeHtml

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);
        }
    };
}
Also used : AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap)

Example 45 with SafeHtml

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>");
}
Also used : VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Aggregations

SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)125 Test (org.junit.Test)34 ImageResource (com.google.gwt.resources.client.ImageResource)25 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)24 UpdateColumnAuditLogEntry (org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)14 Column (com.google.gwt.user.cellview.client.Column)12 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)9 ArrayList (java.util.ArrayList)8 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)7 Cell (com.google.gwt.cell.client.Cell)6 HTML (com.google.gwt.user.client.ui.HTML)6 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)6 ConfirmDialog (org.eclipse.che.ide.api.dialogs.ConfirmDialog)6 TextColumn (com.google.gwt.user.cellview.client.TextColumn)5 LinkedHashMap (java.util.LinkedHashMap)5 Element (com.google.gwt.dom.client.Element)4 Map (java.util.Map)4 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3