List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromTrustedString
public static SafeHtml fromTrustedString(String s)
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static SafeHtml createOpenTag(String tagName, String... attribs) { StringBuilder builder = new StringBuilder(); builder.append("<").append(tagName); for (int i = 0; i < attribs.length; i += 2) { builder.append(' ').append(SafeHtmlUtils.htmlEscape(attribs[i])).append("=\"") .append(SafeHtmlUtils.htmlEscape(attribs[i + 1])).append("\""); }/*from w w w. ja v a 2 s . com*/ builder.append(">"); return SafeHtmlUtils.fromTrustedString(builder.toString()); }
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static SafeHtml concat(SafeHtml... pieces) { StringBuilder builder = new StringBuilder(); for (SafeHtml piece : pieces) { if (piece != null) builder.append(piece.asString()); }//from w w w .ja v a 2 s. c om return SafeHtmlUtils.fromTrustedString(builder.toString()); }
From source file:org.rstudio.studio.client.common.rstudioapi.DialogHtmlSanitizer.java
License:Open Source License
public static SafeHtml sanitizeHtml(String html) { if (StringUtil.isNullOrEmpty(html)) { html = ""; }// w w w. j a v a2s . c om return SafeHtmlUtils.fromTrustedString(dialogSanitize(html)); }
From source file:org.rstudio.studio.client.workbench.views.vcs.git.GitStatusRenderer.java
License:Open Source License
@Override public SafeHtml render(String str) { if (str.length() != 2) return null; ImageResource indexImg = imgForStatus(str.charAt(0)); ImageResource treeImg = imgForStatus(str.charAt(1)); SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status() + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">")); builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(indexImg).getHTML())); builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(treeImg).getHTML())); builder.appendHtmlConstant("</span>"); return builder.toSafeHtml(); }
From source file:org.rstudio.studio.client.workbench.views.vcs.svn.SVNStatusRenderer.java
License:Open Source License
@Override public SafeHtml render(String str) { if (str.length() != 1) return SafeHtmlUtils.fromString(str); ImageResource img = imgForStatus(str.charAt(0)); if (img == null) return SafeHtmlUtils.fromString(str); SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status() + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">")); builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(img).getHTML())); builder.appendHtmlConstant("</span>"); return builder.toSafeHtml(); }
From source file:org.uberfire.ext.widgets.common.client.common.AbstractConcurrentChangePopup.java
License:Apache License
protected AbstractConcurrentChangePopup(final String content, final Command onIgnore, final Command onAction, final String buttonText) { setTitle(CommonConstants.INSTANCE.Error()); add(new ModalBody() { {//from w ww .j a v a 2 s .c om add(uiBinder.createAndBindUi(AbstractConcurrentChangePopup.this)); } }); add(new ModalFooterReOpenIgnoreButtons(this, onAction, onIgnore, buttonText)); message.setHTML(SafeHtmlUtils.fromTrustedString(content)); }
From source file:org.uberfire.ext.widgets.common.client.common.AbstractConcurrentChangePopup.java
License:Apache License
protected AbstractConcurrentChangePopup(final String content, final Command onForceSave, final Command onIgnore, final Command onReOpen) { setTitle(CommonConstants.INSTANCE.Error()); add(new ModalBody() { {//ww w . j a v a 2 s. c o m add(uiBinder.createAndBindUi(AbstractConcurrentChangePopup.this)); } }); add(new ModalFooterForceSaveReOpenCancelButtons(this, onForceSave, onReOpen, onIgnore)); message.setHTML(SafeHtmlUtils.fromTrustedString(content)); }
From source file:org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup.java
License:Apache License
protected YesNoCancelPopup(final String title, final String content, final Command yesCommand, final String yesButtonText, final ButtonType yesButtonType, final IconType yesButtonIconType, final Command noCommand, final String noButtonText, final ButtonType noButtonType, final IconType noButtonIconType, final Command cancelCommand, final String cancelButtonText, final ButtonType cancelButtonType, final IconType cancelButtonIconType) { setTitle(title);// www. ja va 2 s .c o m setHideOtherModals(false); add(new ModalBody() { { add(uiBinder.createAndBindUi(YesNoCancelPopup.this)); } }); add(new ModalFooterYesNoCancelButtons(this, yesCommand, yesButtonText, yesButtonType, yesButtonIconType, noCommand, noButtonText, noButtonType, noButtonIconType, cancelCommand, cancelButtonText, cancelButtonType, cancelButtonIconType)); message.setHTML(SafeHtmlUtils.fromTrustedString(content != null ? content : "")); }
From source file:org.wisepersist.gwtmockito.ng.fakes.FakeClientBundleProvider.java
License:Apache License
/** * Fake invoking on a specified method with arguments. * * @param method The method specified./*from w w w . jav a2s.co m*/ * @param args The arguments specified. * @param name The name specified. * @return The result object. */ private Object doInvoke(final Method method, final Object[] args, final String name) { final Object result; final Class<?> returnType = method.getReturnType(); if (returnType == String.class) { result = name; } else if (returnType == SafeHtml.class) { result = SafeHtmlUtils.fromTrustedString(name); } else if (returnType == SafeUri.class) { result = UriUtils.fromTrustedString(name); } else if (returnType == boolean.class) { result = false; } else if (returnType == int.class) { result = 0; } else if (method.getParameterTypes()[0] == ResourceCallback.class) { result = createFakeForResourceCallback(args[0], name); } else { throw new IllegalArgumentException("Unexpected return type for method " + method.getName()); } return result; }
From source file:org.wisepersist.gwtmockito.ng.fakes.FakeMessagesProvider.java
License:Apache License
/** * Fake invoking on a specified method with arguments. * * @param method The method specified.//from w w w. j ava 2 s .c o m * @param args The arguments specified. * @return The result object. */ private Object doInvoke(final Method method, final Object... args) { final Object result; if (method.getName().equals("ensureInjected")) { result = true; } else if (method.getReturnType() == String.class) { result = buildMessage(method, args); } else if (method.getReturnType() == SafeHtml.class) { result = SafeHtmlUtils.fromTrustedString(buildMessage(method, args)); } else { throw new IllegalArgumentException(method.getName() + " must return either String or SafeHtml"); } return result; }