本文整理汇总了Java中com.google.gwt.safehtml.shared.SafeHtmlUtils类的典型用法代码示例。如果您正苦于以下问题:Java SafeHtmlUtils类的具体用法?Java SafeHtmlUtils怎么用?Java SafeHtmlUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SafeHtmlUtils类属于com.google.gwt.safehtml.shared包,在下文中一共展示了SafeHtmlUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SuggestionMenuItem
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
private SuggestionMenuItem(final Suggestion suggestion) {
super(suggestion.getDisplayString() == null
? suggestion.getChip().getLabel() + " <span class='item-command'>" + suggestion.getChip().getTranslatedCommand() + "</span>"
: SafeHtmlUtils.htmlEscape(suggestion.getDisplayString()) + (suggestion.getHint() == null ? "" : " " + suggestion.getHint()),
true,
new Command() {
@Override
public void execute() {
hideSuggestions();
setStatus(ARIA.suggestionSelected(suggestion.toAriaString(FilterBox.this)));
applySuggestion(suggestion);
iLastValue = getValue();
setAriaLabel(toAriaString());
fireSelectionEvent(suggestion);
ValueChangeEvent.fire(FilterBox.this, getValue());
}
});
setStyleName("item");
getElement().setAttribute("whiteSpace", "nowrap");
iSuggestion = suggestion;
}
示例2: 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);
}
示例3: renderText
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
public static String renderText(MDText[] texts) {
StringBuilder builder = new StringBuilder();
for (MDText text : texts) {
if (text instanceof MDRawText) {
final MDRawText rawText = (MDRawText) text;
builder.append(SafeHtmlUtils.htmlEscape(rawText.getRawText()).replace("\n", "<br/>"));
} else if (text instanceof MDSpan) {
final MDSpan span = (MDSpan) text;
builder.append(spanElement(span.getSpanType(), renderText(span.getChild())));
} else if (text instanceof MDUrl) {
final MDUrl url = (MDUrl) text;
builder.append(urlElement(url));
}
}
return builder.toString();
}
示例4: urlElement
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
private static String urlElement(MDUrl url) {
// Sanitizing URL
String href = UriUtils.sanitizeUri(url.getUrl());
// "DeSanitize" custom url scheme
if (url.getUrl().startsWith("send:")) {
href = UriUtils.encodeAllowEscapes(url.getUrl());
} else {
// HotFixing url without prefix
if (!href.equals("#") && !href.contains("://")) {
href = "http://" + href;
}
}
return "<a " +
"target=\"_blank\" " +
"onClick=\"window.messenger.handleLinkClick(event)\" " +
"href=\"" + href + "\">" +
SafeHtmlUtils.htmlEscape(url.getUrlTitle()) +
"</a>";
}
示例5: ShowcaseTopPanel
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
@Inject
public ShowcaseTopPanel(Image logo, ShowcaseSearchPanel searchPanel) {
super.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
super.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
super.setStyleName("top");
super.setSpacing(1);
logo.setSize("32px", "32px");
super.add(logo);
Anchor anchor = new Anchor();
String text = "<div class=\"brand\"><a href=\"http://cesiumjs.org\">Cesium</a> on GWT Examples</div>";
anchor.setHTML(SafeHtmlUtils.fromTrustedString(text));
super.add(anchor);
super.add(searchPanel);
super.setCellWidth(logo, "10px");
}
示例6: 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);
}
}
示例7: 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;
}
示例8: getText
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
public String getText()
{
String result = "";
if (libraryLoaded && initialized) {
try {
String contentText = getContentText(elementId);
if (contentText == null) {
contentText = "";
}
result = SafeHtmlUtils.fromString(contentText).asString(); // requested as text, so we need to escape the string
} catch (JavaScriptException e) {
GWT.log("Unable to get the content from the TinyMCE editor.", e);
}
} else {
result = super.getText();
if (result == null || result.trim().isEmpty()) {
result = "";
} else {
result = SafeHtmlUtils.fromString(result).asString();
}
}
return result;
}
示例9: loadParticipantItems
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
/**
* Load participant items.
*/
private void loadParticipantItems()
{
NumberNetService.Util.getInstance().getAllParticipants(new AsyncCallback<List<Participant>>()
{
@Override
public void onFailure(Throwable caught)
{
new MessageDialogBox(caught.getMessage()).show();
}
@Override
public void onSuccess(List<Participant> result)
{
trtmByPerson.removeItems();
for (Participant p : result)
{
TreeItem person = new TreeItem(SafeHtmlUtils.fromString(p.getName()));
person.setUserObject("person");
trtmByPerson.addItem(person);
}
}
});
}
示例10: changeHelpPanel
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
/***********************************
****** HELP STUFF ******
***********************************/
private void changeHelpPanel(SubTabs subMenu) {
// change root item
rootItem.setText(subMenu + " Help");
rootItem.removeItems();
SubTabInterface subTabObj = getSubTab(subMenu);
if (subTabObj != null) {
HelpSliderConsts[] helpVals = subTabObj.getHelpSliderContent();
if (helpVals != null) {
for (int i = 0; i < helpVals.length; i++) {
TreeItem helpItem = new TreeItem(SafeHtmlUtils.fromString(helpVals[i].getTitle()));
TreeItem content = new TreeItem(SafeHtmlUtils.fromString(helpVals[i].getContent()));
helpItem.setState(false);
helpItem.addItem(content);
rootItem.addItem(helpItem);
}
}
}
rootItem.setState(true);
resize();
}
示例11: onChannelMessage
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
@Override
public void onChannelMessage(Object p_message)
{
if( p_message instanceof ChatMessage )
{
ChatMessage p_msg = (ChatMessage)p_message;
if( !p_msg.isEmpty() )
{
String text = SafeHtmlUtils.htmlEscape( p_msg.getText() );
text = SmileyCollection.INSTANCE.replace( text );
text = text.replace( "\n", "<br/>" );
HTML label = new HTML( "<b>[" + p_msg.getFromPseudo() + "]</b> " + text );
m_msgList.add( label );
scrollPanel.ensureVisible( label );
}
}
}
示例12: addImageWithLine
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
/**
* @param line
*/
public void addImageWithLine (String line) {
if (line.length() > 0) {
ConfigLine config = parseConfigLine(line);
if (config.url != null && config.url.length() > 0) {
Image image = new Image(config.url);
if (config.name != null) {
image.setTitle(config.name);
image.setAltText(config.caption);
}
((HTMLPanel) this.getWidget()).add(image);
if (config.caption != null) {
((HTMLPanel) this.getWidget())
.add(new HTMLPanel(SafeHtmlUtils.fromTrustedString(
PostHelper.makeMarkup(config.caption))));
}
}
}
}
示例13: render
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
@Override
public void render (com.google.gwt.cell.client.Cell.Context context,
User user, SafeHtmlBuilder sb) {
String summary;
if (user.summary != null) {
summary = PostHelper.makeMarkup(user.summary);
} else {
summary = "<p class=\"text-muted text-justify\">"
+ SafeHtmlUtils.fromString(UserHelper.name(user)).asString()
+ " has not entered a user summary.</p>";
}
RENDERER.render(sb, SafeHtmlUtils.fromString(UserHelper.name(user)),
SafeHtmlUtils.fromString("@" + user.username),
UriUtils.fromString(user.avatar + "?s=80&default=retro"),
SafeHtmlUtils.fromTrustedString(summary));
}
示例14: AbstractConcurrentChangePopup
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
protected AbstractConcurrentChangePopup(final String content,
final Command onIgnore,
final Command onAction,
final String buttonText) {
setTitle(CommonConstants.INSTANCE.Error());
add(new ModalBody() {{
add(uiBinder.createAndBindUi(AbstractConcurrentChangePopup.this));
}});
add(new ModalFooterReOpenIgnoreButtons(this,
onAction,
onIgnore,
buttonText));
message.setHTML(SafeHtmlUtils.fromTrustedString(content));
}
示例15: render
import com.google.gwt.safehtml.shared.SafeHtmlUtils; //导入依赖的package包/类
@Override
public void render(Context context, PlayerDTO value, SafeHtmlBuilder sb) {
String playerClass = "";
if (comms.contains(value.getId())) {
playerClass = "participant captain";
} else {
playerClass = "participant " + baseClass;
}
sb.appendHtmlConstant("<span class=\"" + playerClass + "\" title=\"" + SafeHtmlUtils.fromString(value.getName()).asString()
+ "\">");
value.buildInfo(sb);
if (value.getSide() == Side.MERC) {
sb.appendEscaped(" [MERC]");
}
sb.appendHtmlConstant("</span>");
}