本文整理汇总了Java中com.google.gwt.i18n.shared.BidiFormatter类的典型用法代码示例。如果您正苦于以下问题:Java BidiFormatter类的具体用法?Java BidiFormatter怎么用?Java BidiFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BidiFormatter类属于com.google.gwt.i18n.shared包,在下文中一共展示了BidiFormatter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOptionText
import com.google.gwt.i18n.shared.BidiFormatter; //导入依赖的package包/类
/**
* Sets the text of an option element. If the direction of the text is opposite to the page's direction, also wraps it with Unicode bidi formatting
* characters to prevent garbling, and indicates that this was done by setting the option's <code>BIDI_ATTR_NAME</code> custom attribute.
*
* @param option an option element
* @param text text to be set to the element
* @param dir the text's direction. If {@code null} and direction estimation is turned off, direction is ignored.
*/
protected void setOptionText(OptionElement option, String text, Direction dir) {
if (dir == null && estimator != null) {
dir = estimator.estimateDirection(text);
}
if (dir == null) {
option.setText(text);
option.removeAttribute(BIDI_ATTR_NAME);
} else {
String formattedText = BidiFormatter.getInstanceForCurrentLocale().unicodeWrapWithKnownDir(dir, text, false /* isHtml */, false /* dirReset */);
option.setText(formattedText);
if (formattedText.length() > text.length()) {
option.setAttribute(BIDI_ATTR_NAME, "");
} else {
option.removeAttribute(BIDI_ATTR_NAME);
}
}
}