本文整理汇总了Java中com.google.gwt.dom.client.OptionElement.setText方法的典型用法代码示例。如果您正苦于以下问题:Java OptionElement.setText方法的具体用法?Java OptionElement.setText怎么用?Java OptionElement.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.dom.client.OptionElement
的用法示例。
在下文中一共展示了OptionElement.setText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOptionText
import com.google.gwt.dom.client.OptionElement; //导入方法依赖的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);
}
}
}
示例2: setupLocaleSelect
import com.google.gwt.dom.client.OptionElement; //导入方法依赖的package包/类
private void setupLocaleSelect() {
final SelectElement select = (SelectElement) Document.get().getElementById(LANG_ELEMENT_ID);
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
String[] localeNames = LocaleInfo.getAvailableLocaleNames();
for (String locale : localeNames) {
if (!DEFAULT_LOCALE.equals(locale)) {
String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
OptionElement option = Document.get().createOptionElement();
option.setValue(locale);
option.setText(displayName);
select.add(option, null);
if (locale.equals(currentLocale)) {
select.setSelectedIndex(select.getLength() - 1);
}
}
}
EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {
@Override
public boolean onChange(ChangeEvent event, Element context) {
UrlBuilder builder = Location.createUrlBuilder().setParameter(
LOCALE_URLBUILDER_PARAMETER, select.getValue());
Window.Location.replace(builder.buildString());
localeService.storeLocale(select.getValue());
return true;
}
});
}
示例3: createOption
import com.google.gwt.dom.client.OptionElement; //导入方法依赖的package包/类
protected OptionElement createOption(String item, String value)
{
OptionElement option = Document.get().createOptionElement();
option.setText(item);
option.setInnerText(item);
option.setValue(value);
return option;
}
示例4: setItemText
import com.google.gwt.dom.client.OptionElement; //导入方法依赖的package包/类
@Override
public void setItemText(int index, String text) {
if (text == null) {
throw new NullPointerException("Cannot set an option to have null text");
}
OptionElement option = getOption(index);
option.setText(text);
}
示例5: createOption
import com.google.gwt.dom.client.OptionElement; //导入方法依赖的package包/类
protected OptionElement createOption(String item, String value) {
OptionElement option = Document.get().createOptionElement();
option.setText(item);
option.setInnerText(item);
option.setValue(value);
return option;
}
示例6: addItemWithStyle
import com.google.gwt.dom.client.OptionElement; //导入方法依赖的package包/类
public void addItemWithStyle(String item, String value) {
final SelectElement select = getElement().cast();
final OptionElement option = Document.get().createOptionElement();
option.setText(item);
option.setValue(value);
option.setClassName(styleName);
select.add(option, null);
}
示例7: setupLocaleSelect
import com.google.gwt.dom.client.OptionElement; //导入方法依赖的package包/类
private void setupLocaleSelect() {
final SelectElement select = (SelectElement) Document.get().getElementById("lang");
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
String[] localeNames = LocaleInfo.getAvailableLocaleNames();
for (String locale : localeNames) {
if (!DEFAULT_LOCALE.equals(locale)) {
String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
OptionElement option = Document.get().createOptionElement();
option.setValue(locale);
option.setText(displayName);
select.add(option, null);
if (locale.equals(currentLocale)) {
select.setSelectedIndex(select.getLength() - 1);
}
}
}
EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {
@Override
public boolean onChange(ChangeEvent event, Element context) {
UrlBuilder builder = Location.createUrlBuilder().setParameter(
"locale", select.getValue());
Window.Location.replace(builder.buildString());
localeService.storeLocale(select.getValue());
return true;
}
});
}