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();
}
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));
}
}
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));
}
}
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()));
}
}
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)));
}
}
}
Aggregations