Search in sources :

Example 46 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project ovirt-engine by oVirt.

the class VMsTree method getSnapshotNode.

private TreeItem getSnapshotNode(List<DiskImage> disks) {
    VerticalPanel vPanel = new VerticalPanel();
    // $NON-NLS-1$
    vPanel.setWidth("100%");
    for (DiskImage disk : disks) {
        HorizontalPanel panel = new HorizontalPanel();
        ImageResource image = resources.snapshotImage();
        String name = disk.getDescription();
        // $NON-NLS-1$
        addItemToPanel(panel, new Image(image), "25px");
        // $NON-NLS-1$
        addTextBoxToPanel(panel, new StringValueLabel(), name, "");
        // $NON-NLS-1$ //$NON-NLS-2$
        addTextBoxToPanel(panel, new StringValueLabel(), "", "80px");
        // $NON-NLS-1$ //$NON-NLS-2$
        addTextBoxToPanel(panel, new StringValueLabel(), "", "160px");
        // $NON-NLS-1$
        addValueLabelToPanel(panel, new DiskSizeLabel<Long>(), disk.getSizeInGigabytes(), "110px");
        // $NON-NLS-1$
        addValueLabelToPanel(panel, new DiskSizeLabel<Double>(SizeConverter.SizeUnit.GiB), disk.getActualSize(), "110px");
        // $NON-NLS-1$
        addValueLabelToPanel(panel, new FullDateTimeLabel(), disk.getCreationDate(), "140px");
        panel.setSpacing(1);
        // $NON-NLS-1$
        panel.setWidth("100%");
        vPanel.add(panel);
    }
    TreeItem treeItem = new TreeItem(vPanel);
    // $NON-NLS-1$
    treeItem.setUserObject(disks.get(0).getId() + "snapshot");
    return treeItem;
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) Image(com.google.gwt.user.client.ui.Image) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) StringValueLabel(org.ovirt.engine.ui.common.widget.label.StringValueLabel) FullDateTimeLabel(org.ovirt.engine.ui.webadmin.widget.label.FullDateTimeLabel) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ImageResource(com.google.gwt.resources.client.ImageResource) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 47 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project ovirt-engine by oVirt.

the class BrickStatusCell method render.

@Override
public void render(Context context, GlusterBrickEntity brick, SafeHtmlBuilder sb, String id) {
    // Nothing to render if no brick is provided:
    if (brick == null) {
        return;
    }
    // Find the image corresponding to the status of the brick:
    GlusterStatus status = brick.getStatus();
    ImageResource statusImage = null;
    switch(status) {
        case DOWN:
            statusImage = resources.downImage();
            break;
        case UP:
            statusImage = resources.upImage();
            break;
        case UNKNOWN:
            statusImage = resources.questionMarkImage();
            break;
        default:
            statusImage = resources.downImage();
    }
    // Generate the HTML for the image:
    SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML());
    if (brick.getUnSyncedEntries() != null && brick.getUnSyncedEntries() > 0) {
        SafeHtml alertImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.alertImage()).getHTML());
        sb.append(templates.statusWithAlertTemplate(statusImageHtml, alertImageHtml, id, status.toString()));
    } else {
        sb.append(templates.statusTemplate(statusImageHtml, id, status.toString()));
    }
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)

Example 48 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project ovirt-engine by oVirt.

the class GlusterVolumeSnapshotStatusCell method render.

@Override
public void render(Context context, GlusterVolumeSnapshotEntity snapshot, SafeHtmlBuilder sb, String id) {
    // Nothing to render if no snapshot is provided:
    if (snapshot == null) {
        return;
    }
    // Find the image corresponding to the status of the brick:
    GlusterSnapshotStatus status = snapshot.getStatus();
    ImageResource statusImage = null;
    switch(status) {
        case ACTIVATED:
            statusImage = resources.upImage();
            break;
        case DEACTIVATED:
            statusImage = resources.downImage();
            break;
        case UNKNOWN:
            statusImage = resources.questionMarkImage();
            break;
        default:
            statusImage = resources.downImage();
    }
    // Generate the HTML for the image:
    SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML());
    sb.append(templates.statusTemplate(statusImageHtml, id, status.toString()));
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) GlusterSnapshotStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotStatus)

Example 49 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project ovirt-engine by oVirt.

the class VmStatusCell method render.

@Override
public void render(Context context, VM vm, SafeHtmlBuilder sb, String id) {
    // Nothing to render if no vm is provided:
    if (vm == null) {
        return;
    }
    // Find the image corresponding to the status of the vm:
    VMStatus status = vm.getStatus();
    ImageResource statusImage;
    switch(status) {
        case Up:
            if (vm.isRunOnce()) {
                statusImage = resources.runOnceUpImage();
            } else {
                statusImage = resources.vmStatusRunning();
            }
            break;
        case SavingState:
            statusImage = resources.vmStatusWait();
            break;
        case RestoringState:
            statusImage = resources.vmStatusWait();
            break;
        case PoweringUp:
            statusImage = resources.vmStatusStarting();
            break;
        case PoweringDown:
            statusImage = resources.vmStatusPoweringDown();
            break;
        case RebootInProgress:
            statusImage = resources.rebootInProgress();
            break;
        case WaitForLaunch:
            statusImage = resources.waitForLaunch();
            break;
        case ImageLocked:
            statusImage = resources.vmStatusWait();
            break;
        case MigratingFrom:
        case MigratingTo:
            statusImage = resources.migrationImage();
            break;
        case Suspended:
            statusImage = resources.suspendedImage();
            break;
        case Paused:
            statusImage = resources.pauseImage();
            break;
        case Unknown:
        case Unassigned:
            statusImage = resources.questionMarkImage();
            break;
        case NotResponding:
            statusImage = resources.questionMarkImage();
            break;
        default:
            statusImage = resources.downStatusImage();
            break;
    }
    // Generate the HTML for status image
    SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML());
    if (vm.getLockInfo() != null && vm.getLockInfo().isExclusive()) {
        ImageResource lockImageResource = resources.vmLocked();
        // Get the image html
        AbstractImagePrototype imagePrototype = AbstractImagePrototype.create(lockImageResource);
        SafeHtml lockImageHtml = SafeHtmlUtils.fromTrustedString(imagePrototype.getHTML());
        statusImageHtml = templates.lockedStatusTemplate(lockImageHtml, statusImageHtml);
    }
    if (VmStatusColumn.needsAlert(vm)) {
        sb.append(templates.statusWithAlertTemplate(statusImageHtml, getAlertImageResource(vm), id, status.toString()));
    } else {
        sb.append(templates.statusTemplate(statusImageHtml, id, status.toString()));
    }
}
Also used : AbstractImagePrototype(com.google.gwt.user.client.ui.AbstractImagePrototype) ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus)

Example 50 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project ovirt-engine by oVirt.

the class VmStatusCell method getAlertImageResource.

private static SafeHtml getAlertImageResource(VM vm) {
    ImageResource alertImageResource = resources.alertImage();
    AbstractImagePrototype imagePrototype = AbstractImagePrototype.create(alertImageResource);
    String html = imagePrototype.getHTML();
    return SafeHtmlUtils.fromTrustedString(html);
}
Also used : AbstractImagePrototype(com.google.gwt.user.client.ui.AbstractImagePrototype) ImageResource(com.google.gwt.resources.client.ImageResource)

Aggregations

ImageResource (com.google.gwt.resources.client.ImageResource)62 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)24 Image (com.google.gwt.user.client.ui.Image)11 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)9 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)7 Element (com.google.gwt.dom.client.Element)6 Column (com.google.gwt.user.cellview.client.Column)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Test (org.junit.Test)4 ImageResourceCell (com.google.gwt.cell.client.ImageResourceCell)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 ArrayList (java.util.ArrayList)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)3 Context (com.google.gwt.cell.client.Cell.Context)2 JsArray (com.google.gwt.core.client.JsArray)2 JsArrayString (com.google.gwt.core.client.JsArrayString)2