本文整理匯總了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);
}
}
}