本文整理汇总了Java中com.google.gwt.safehtml.shared.SafeHtmlUtils.fromTrustedString方法的典型用法代码示例。如果您正苦于以下问题:Java SafeHtmlUtils.fromTrustedString方法的具体用法?Java SafeHtmlUtils.fromTrustedString怎么用?Java SafeHtmlUtils.fromTrustedString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.safehtml.shared.SafeHtmlUtils
的用法示例。
在下文中一共展示了SafeHtmlUtils.fromTrustedString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createColumnList
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
private ColumnModel<LayerDef> createColumnList(LayerDefProperties props,
RowExpander<LayerDef> rowExpander) {
rowExpander.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
rowExpander.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<LayerDef, String> nameColumn = new ColumnConfig<LayerDef, String>(
props.name(), 200, SafeHtmlUtils.fromTrustedString("<b>"
+ UIMessages.INSTANCE.layerManagerToolText() + "</b>"));
nameColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<LayerDef, String> typeColumn = new ColumnConfig<LayerDef, String>(
props.type(), 75, UICatalogMessages.INSTANCE.type());
typeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
typeColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<LayerDef, ImageResource> iconColumn = new ColumnConfig<LayerDef, ImageResource>(
props.icon(), 32, "");
iconColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
iconColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
iconColumn.setCell(new ImageResourceCell() {
@Override
public void render(Context context, ImageResource value, SafeHtmlBuilder sb) {
super.render(context, value, sb);
}
});
List<ColumnConfig<LayerDef, ?>> columns = new ArrayList<ColumnConfig<LayerDef, ?>>();
columns.add(rowExpander);
columns.add(iconColumn);
columns.add(nameColumn);
columns.add(typeColumn);
return new ColumnModel<LayerDef>(columns);
}
示例2: getImageHtml
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
private SafeHtml getImageHtml(ImageResource res, VerticalAlignmentConstant valign) {
AbstractImagePrototype proto = AbstractImagePrototype.create(res);
SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML());
// Create the wrapper based on the vertical alignment.
SafeStylesBuilder cssStyles =
new SafeStylesBuilder().appendTrustedString(direction + ":0px;");
if (HasVerticalAlignment.ALIGN_TOP == valign) {
return templates.imageWrapperTop(cssStyles.toSafeStyles(), image);
} else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) {
return templates.imageWrapperBottom(cssStyles.toSafeStyles(), image);
} else {
int halfHeight = (int) Math.round(res.getHeight() / 2.0);
cssStyles.appendTrustedString("margin-top:-" + halfHeight + "px;");
return templates.imageWrapperMiddle(cssStyles.toSafeStyles(), image);
}
}
示例3: getHTML
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
public SafeHtml getHTML() {
SafeHtml result = null;
if (libraryLoaded && initialized) {
try {
String contentHtml = getContentHtml(elementId); // TinyMCE takes care of the sanitization.
if (contentHtml == null || contentHtml.trim().isEmpty()) {
return SafeHtmlUtils.fromSafeConstant("");
}
// Remove the root block <p></p> that gets added automatically by TinyMCE
if (contentHtml.startsWith("<p>") && contentHtml.endsWith("</p>")) {
contentHtml = contentHtml.substring(3, contentHtml.length() - 4);
}
result = SafeHtmlUtils.fromTrustedString(contentHtml);
} catch (JavaScriptException e) {
GWT.log("Unable to get the content from the TinyMCE editor.", e);
}
} else {
String text = super.getText();
if (text == null || text.trim().isEmpty()) {
return SafeHtmlUtils.fromSafeConstant("");
} else {
return SafeHtmlUtils.fromString(text);
}
}
return result;
}
示例4: toSafeHtml
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
SafeHtml toSafeHtml(boolean withFormatting) {
// NOTE :: Embedded operations are LOST using this method ....
StringBuilder sb = new StringBuilder();
for (StyledParagraphItem i : _items) {
final String text = i.getText();
final String style = i.getStyle();
if (withFormatting && style != null) {
sb.append("<span style=\"");
sb.append(SafeHtmlUtils.htmlEscape(style));
sb.append("\">");
if (text != null && " ".equals(text)) {
sb.append(" ");
} else {
sb.append(SafeHtmlUtils.htmlEscape(text));
}
sb.append("</span>");
} else {
sb.append(SafeHtmlUtils.htmlEscape(text));
}
}
final SafeHtml safeHtml = SafeHtmlUtils.fromTrustedString(sb.toString());
return safeHtml;
}
示例5: createDivStart
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
public SafeHtml createDivStart(String title,
String defaultValue,
String cssClasses) {
if (title == null || "".equals(title)) {
title = defaultValue;
}
final String css = cssClasses == null ? "" : "class=\"" + cssClasses + "\"";
return SafeHtmlUtils.fromTrustedString("<div title=\"" + SafeHtmlUtils.htmlEscape(title.trim()) + "\" " + css + " >");
}
示例6: getExpandImageHtml
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
private SafeHtml getExpandImageHtml()
{
StringBuilder sb = new StringBuilder();
sb.append( "<img src='" );
if( !hasChilds() )
sb.append( "" );
else if( getExpanded() )
sb.append( this.treeTable.treeMinus.getSafeUri().asString() );
else
sb.append( this.treeTable.treePlus.getSafeUri().asString() );
sb.append( "'></img>" );
return SafeHtmlUtils.fromTrustedString( sb.toString() );
}
示例7: makeImage
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
private static SafeHtml makeImage(ImageResource resource) {
AbstractImagePrototype proto = AbstractImagePrototype.create(resource);
String html = proto
.getHTML()
.replace("style='", "style='position:absolute;right:0px;top:0px;");
return SafeHtmlUtils.fromTrustedString(html);
}
示例8: createColumnList
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
private ColumnModel<VehicleJSO> createColumnList(VehicleJSOProperties props,
RowExpander<VehicleJSO> rowExpander) {
rowExpander.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
rowExpander.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<VehicleJSO, String> nameColumn = new ColumnConfig<VehicleJSO, String>(
props.name(), 200, SafeHtmlUtils.fromTrustedString("<b>"
+ UISgfMessages.INSTANCE.nameColumn() + "</b>"));
nameColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<VehicleJSO, String> plateColumn = new ColumnConfig<VehicleJSO, String>(
props.plate(), 200, SafeHtmlUtils.fromTrustedString("<b>"
+ UISgfMessages.INSTANCE.plateColumn() + "</b>"));
plateColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<VehicleJSO, String> statusColumn = new ColumnConfig<VehicleJSO, String>(
props.status(), 200, SafeHtmlUtils.fromTrustedString("<b>"
+ UISgfMessages.INSTANCE.statusColumn() + "</b>"));
statusColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<VehicleJSO, String> lastRevisionDateColumn = new ColumnConfig<VehicleJSO, String>(
props.lastRevisionDate(), 200, SafeHtmlUtils.fromTrustedString("<b>"
+ UISgfMessages.INSTANCE.lastReviewColumn() + "</b>"));
lastRevisionDateColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<VehicleJSO, String> kmRevisionColumn = new ColumnConfig<VehicleJSO, String>(
props.kmsLeftForRevision(), 200, SafeHtmlUtils.fromTrustedString("<b>"
+ UISgfMessages.INSTANCE.kmForReviewColumn() + "</b>"));
kmRevisionColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
List<ColumnConfig<VehicleJSO, ?>> columns = new ArrayList<ColumnConfig<VehicleJSO, ?>>();
columns.add(rowExpander);
columns.add(nameColumn);
columns.add(plateColumn);
columns.add(statusColumn);
columns.add(lastRevisionDateColumn);
columns.add(kmRevisionColumn);
return new ColumnModel<VehicleJSO>(columns);
}
示例9: menuItemWithShortcut
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
MenuItem menuItemWithShortcut(String text, String shortcut, MyCommand cmd) {
final String edithtml="<div style=\"display:inline-block;width:80px;\">";
String sn=edithtml + text + "</div>" + shortcut;
return new MenuItem(SafeHtmlUtils.fromTrustedString(sn), cmd);
}
示例10: CheckboxAlignedMenuItem
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
public CheckboxAlignedMenuItem(String s, Command cmd) {
super(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+" </div>"+s), cmd);
}
示例11: createDivEnd
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
public SafeHtml createDivEnd() {
return SafeHtmlUtils.fromTrustedString("</div>");
}
示例12: sanitizeHtml
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
/**
* HTML-sanitizes a string.
*
* <p>
* The input string is processed as described above. The result of sanitizing
* the string is guaranteed to be safe to use (with respect to XSS
* vulnerabilities) in HTML contexts, and is returned as an instance of the
* {@link SafeHtml} type.
*
* @param html the input String
* @return a sanitized SafeHtml instance
*/
public static SafeHtml sanitizeHtml(String html) {
if (html == null) {
throw new NullPointerException("html is null");
}
return SafeHtmlUtils.fromTrustedString(simpleSanitize(html));
}
示例13: imageItemHTML
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
/**
* Generates HTML for a tree item with an attached icon.
*
* @param imageProto the image prototype to use
* @param title the title of the item
* @return the resultant HTML
*/
private SafeHtml imageItemHTML(ImageResource imageProto,
String title) {
return SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(imageProto)
.getHTML() + " " + title);
}
示例14: LSHTML
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入方法依赖的package包/类
static SafeHtml LSHTML(String s) { return SafeHtmlUtils.fromTrustedString(LS(s)); }