Search in sources :

Example 76 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.

the class ErrorMessageFormatter method formatMessages.

public static String formatMessages(List<Message> values) {
    // If one error message without description no need to format
    if (values.size() == 1) {
        Message msg = values.get(0);
        if (msg.getDescription() == null || "".equals(msg.getDescription())) {
            // $NON-NLS-1$
            return msg.getText();
        }
    }
    SafeHtmlBuilder allSb = new SafeHtmlBuilder();
    // $NON-NLS-1$
    allSb.append(SafeHtmlUtils.fromTrustedString("<br/><br/>"));
    Map<String, Set<String>> desc2msgs = getDescription2MsgMap(values);
    for (Map.Entry<String, Set<String>> entry : desc2msgs.entrySet()) {
        String desc = entry.getKey();
        SafeHtml sh = buildItemList(entry.getValue());
        if (!"".equals(desc)) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            allSb.append(SafeHtmlUtils.fromString(desc + ":"));
        }
        allSb.append(sh);
    }
    return allSb.toSafeHtml().asString();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Message(org.ovirt.engine.ui.frontend.Message) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) HashMap(java.util.HashMap) Map(java.util.Map)

Example 77 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.

the class LinkCell method render.

/**
 * Render as if it is an overflow truncation {@link TextCell} but with a text value as
 * a link instead of normal text.
 */
@Override
public void render(Context context, String value, SafeHtmlBuilder sb, String id) {
    if (value != null) {
        SafeHtml safeValue = SafeHtmlUtils.fromString(value);
        sb.append(template.containerAndLink(getStyleClass(), getRenderElementId(context), safeValue));
    }
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Example 78 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.

the class LunSelectionCell method render.

@Override
public void render(Context context, LunModel value, SafeHtmlBuilder sb, String id) {
    ImageResourceCell imageCell = new ImageResourceCell();
    // $NON-NLS-1$
    imageCell.setStyle("text-align: center;");
    if (value.isRemoveLunSelected()) {
        // $NON-NLS-1$
        imageCell.setStyle("text-align: center; opacity: 0.2; filter: alpha(opacity=20);");
    }
    if (value.getIsIncluded()) {
        // ImageResourceCell sets the id
        imageCell.render(context, resources.okSmallImage(), sb, id);
    } else if (!value.getIsAccessible()) {
        // ImageResourceCell sets the id
        imageCell.render(context, resources.logWarningImage(), sb, id);
    } else if (!multiSelection) {
        boolean checked = value.getIsSelected();
        boolean disabled = value.getIsGrayedOut();
        // $NON-NLS-1$
        String inputId = id + "_input";
        // $NON-NLS-1$
        String type = "radio";
        SafeHtml input;
        if (checked && !disabled) {
            input = templates.inputChecked(inputId, type);
        } else if (checked && disabled) {
            input = templates.inputCheckedDisabled(inputId, type);
        } else if (!checked && !disabled) {
            input = templates.inputUnchecked(inputId, type);
        } else {
            input = templates.inputUncheckedDisabled(inputId, type);
        }
        sb.append(templates.span(id, input));
    }
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Example 79 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.

the class DecoratedImageResourceCell method render.

@Override
public void render(Context context, ImageWithDecorator value, SafeHtmlBuilder sb, String id) {
    if (value != null) {
        // $NON-NLS-1$
        SafeHtml mainImageHtml = SafeHtmlUtils.fromTrustedString("");
        // $NON-NLS-1$
        SafeHtml decorateImageHtml = SafeHtmlUtils.fromTrustedString("");
        if (value.getImage() != null) {
            mainImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(value.getImage()).getHTML());
        }
        if (value.getDecorator() != null) {
            decorateImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(value.getDecorator()).getHTML());
        }
        sb.append(template.doubleImageContainer(mainImageHtml, decorateImageHtml, value.getDecoratorPositionLeft(), value.getDecoratorPositionTop(), id, value.getStatus()));
    }
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Example 80 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.

the class TextCell method render.

@Override
public void render(Context context, String value, SafeHtmlBuilder sb, String id) {
    if (value != null) {
        SafeHtml safeHtmlValue = SafeHtmlUtils.fromString(value);
        if (maxTextLength >= 0) {
            // using manual truncation
            SafeHtml renderedValue = getRenderedValue(safeHtmlValue);
            sb.append(template.textContainer(getStyleClass(), getRenderElementId(context), renderedValue));
        } else if (useOverflowTruncation) {
            // using overflow truncation
            sb.append(template.textContainerWithDetection(getStyleClass(), getRenderElementId(context), safeHtmlValue));
        } else {
            // no truncation at all
            sb.append(template.textContainer(getStyleClass(), getRenderElementId(context), SafeHtmlUtils.fromString(value)));
        }
    }
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Aggregations

SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)129 Test (org.junit.Test)38 ImageResource (com.google.gwt.resources.client.ImageResource)25 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)25 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)11 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)9 ArrayList (java.util.ArrayList)8 Cell (com.google.gwt.cell.client.Cell)7 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)7 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 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)4 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3 Element (com.google.gwt.dom.client.Element)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3