Refine search
/** * Creates a hyperlink with its html and target history token specified. * * @param html the hyperlink's safe html * @param targetHistoryToken the history token to which it will link * @see #setTargetHistoryToken */ public Hyperlink(SafeHtml html, String targetHistoryToken) { this(html.asString(), true, targetHistoryToken); }
SafeHtmlBuilder accum = new SafeHtmlBuilder(); wordBounds.endIndex); cursor = wordBounds.endIndex; accum.appendEscaped(part1); accum.appendHtmlConstant("<strong>"); accum.appendEscaped(part2); accum.appendHtmlConstant("</strong>"); accum.appendEscaped(formattedSuggestion.substring(cursor)); MultiWordSuggestion suggestion = createSuggestion(formattedSuggestion, accum.toSafeHtml().asString()); suggestions.add(suggestion);
@Override public void render(ButtonCellBase<C> cell, Context context, C value, SafeHtmlBuilder sb) { SafeHtmlBuilder classes = new SafeHtmlBuilder(); classes.appendEscaped(style.buttonCellBase()); Decoration decoration = cell.getDecoration(); if (decoration == Decoration.PRIMARY) { classes.appendEscaped(" " + style.buttonCellBasePrimary()); } else if (decoration == Decoration.NEGATIVE) { classes.appendEscaped(" " + style.buttonCellBaseNegative()); attributes.append("accessKey=\"").append(SafeHtmlUtils.htmlEscape("" + accessKey)); attributes.append("\" "); StringBuilder openTag = new StringBuilder(); openTag.append("<button type=\"button\""); openTag.append(" class=\"" + classes.toSafeHtml().asString() + "\""); openTag.append(" tabindex=\"" + tabIndex + "\" "); openTag.append(attributes.toString()).append(">"); sb.append(SafeHtmlUtils.fromTrustedString(openTag.toString())); sb.append(content); sb.appendHtmlConstant("</button>");
public static void addMessage(String message, DivElement divContainer){ final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); safeHtmlBuilder.appendHtmlConstant(divContainer.getInnerHTML()). appendHtmlConstant("<br/>"). append(SafeHtmlUtils.fromString(message)); divContainer.setInnerHTML(safeHtmlBuilder.toSafeHtml().asString()); }
/** * render a header and return the value as html * * @param group the header to render * @return the string value */ public String renderGroupHeader(G group) { SafeHtmlBuilder headerBuilder = new SafeHtmlBuilder(); header.render(headerBuilder, group); return headerBuilder.toSafeHtml().asString(); }
public static String formatErrorMessages(List<String> values) { if (values.size() == 1) { return values.get(0); } SafeHtmlBuilder allSb = new SafeHtmlBuilder(); allSb.append(SafeHtmlUtils.fromTrustedString("<br/><br/>")); //$NON-NLS-1$ SafeHtml sh = buildItemList(values); allSb.append(sh); return allSb.toSafeHtml().asString(); }
/** * @see BidiFormatter#spanWrap(String, boolean, boolean) * * @param html The input html * @param dirReset Whether to append a trailing unicode bidi mark matching the * context direction, when needed, to prevent the possible garbling * of whatever may follow {@code html} * @return Input html after applying the above processing. */ public SafeHtml spanWrap(SafeHtml html, boolean dirReset) { return SafeHtmlUtils.fromTrustedString( spanWrapBase(html.asString(), true, dirReset)); }
public void onTestConnectionError(Object message, Throwable throwable) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestFailedMessage) + "\n"); builder.appendEscapedLines(throwable.getMessage()); popupsUtil.showErrorPopup(builder.toSafeHtml().asString()); }
public static void replaceExpression(HTMLElement context, String expression, Object value) { SafeHtml safeValue; if (value instanceof SafeHtml) { safeValue = (SafeHtml) value; } else { safeValue = SafeHtmlUtils.fromString(String.valueOf(value)); } replaceNestedExpressionInText(context, expression, safeValue.asString()); replaceNestedExpressionInAttributes(context, expression, safeValue.asString()); // The call above does not catch the attributes in 'context', we need to replace them explicitly. replaceExpressionInAttributes(context, expression, safeValue.asString()); }
@Override public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { sb.append(SafeHtmlUtils.fromTrustedString("<div title='" + value.asString() + "'>")); sb.append(value); sb.appendHtmlConstant("</div>"); } } });
private void renderEscaped(String iri, StringBuilder sb) { SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder(); htmlBuilder.appendEscaped(iri); sb.append(htmlBuilder.toSafeHtml().asString()); }
/** * render a header and return the value as html * * @param group the header to render * @return the string value */ public String renderGroupHeader(G group) { SafeHtmlBuilder headerBuilder = new SafeHtmlBuilder(); header.render(headerBuilder, group); return headerBuilder.toSafeHtml().asString(); }
/** * @see BidiFormatter#unicodeWrap(String, boolean, boolean) * * @param html The input html * @param dirReset Whether to append a trailing unicode bidi mark matching the * context direction, when needed, to prevent the possible garbling * of whatever may follow {@code html} * @return Input html after applying the above processing. */ public SafeHtml unicodeWrap(SafeHtml html, boolean dirReset) { return SafeHtmlUtils.fromTrustedString( unicodeWrapBase(html.asString(), true, dirReset)); }
public void onTestConnectionSuccess(TestResult response) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (response.isTestPassed()) { builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestSuccessfulMessage) + "\n"); } else { builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestFailedMessage) + "\n"); } builder.appendEscapedLines(response.getMessage()); popupsUtil.showInformationPopup(builder.toSafeHtml().asString()); }
@Override public String getValue() { return SafeHtmlUtils.fromString(header.getElement().getInnerHTML()).asString(); } }
private void renderEscapedIRI(IRI iri, StringBuilder sb) { SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder(); htmlBuilder.appendEscaped(iri.toString()); sb.append(htmlBuilder.toSafeHtml().asString()); }
/** * Creates a button with the given HTML caption. * * @param html the HTML caption */ public SubmitButton(SafeHtml html) { this(html.asString()); }
@Test public void testNoActions() { kebabActionCell.setActions(emptyList()); final SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder(); kebabActionCell.render(null, null, htmlBuilder); assertTrue(htmlBuilder.toSafeHtml().asString().isEmpty()); verifyZeroInteractions(kebabMenus, document); }
/** * Inserts an attribute into the first tag found in a {@code safeHtml} template. * This method assumes that the {@code safeHtml} template begins with an open HTML tag. * {@code SafeHtml} templates produced by UiBinder always meet these conditions. * <p> * This method does not attempt to ensure {@code atributeName} and {@code attributeValue} * contain safe values. * * @returns the {@code safeHtml} template with "{@code attributeName}={@code attributeValue}" * inserted as an attribute of the first tag found */ protected static SafeHtml stampUiRendererAttribute(SafeHtml safeHtml, String attributeName, String attributeValue) { String html = safeHtml.asString(); int endOfFirstTag = html.indexOf(">"); assert endOfFirstTag > 1 : "Safe html template does not start with an HTML open tag"; if (html.charAt(endOfFirstTag - 1) == '/') { endOfFirstTag--; } html = html.substring(0, endOfFirstTag) + " " + attributeName + "=\"" + attributeValue + "\"" + html.substring(endOfFirstTag); return SafeHtmlUtils.fromTrustedString(html); }
@Override public String getValue() { return SafeHtmlUtils.fromString(header.getElement().getInnerHTML()).asString(); } }