本文整理汇总了Java中com.google.gwt.user.client.ui.ListBox.setItemSelected方法的典型用法代码示例。如果您正苦于以下问题:Java ListBox.setItemSelected方法的具体用法?Java ListBox.setItemSelected怎么用?Java ListBox.setItemSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.ListBox
的用法示例。
在下文中一共展示了ListBox.setItemSelected方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveAllItems
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private Set<String> moveAllItems(ListBox source, ListBox target) {
final Set<String> movedItems = new HashSet<String>();
int size = source.getItemCount();
for (int i = 0; i < size; i++) {
movedItems.add(source.getValue(i));
final String text = source.getItemText(i);
final String value = source.getValue(i);
target.addItem(text, value);
target.setItemSelected(target.getItemCount() - 1, true);
}
target.setFocus(true);
if (source.getItemCount() > 0) {
target.setSelectedIndex(0);
}
source.clear();
return movedItems;
}
示例2: addDropDown
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
/**
* To add Drop Down.
*
* @param row int
* @param sampleValueList List<String>
* @param selectedValue String
* @param htmlID String
* @param elementMap Map<String, Widget>
* @return ListBox
*/
public ListBox addDropDown(int row, List<String> sampleValueList, String selectedValue, String htmlID,
Map<String, Widget> elementMap) {
ListBox fieldValue = new ListBox();
elementMap.put(htmlID, fieldValue);
fieldValue.getElement().setId(htmlID);
fieldValue.setVisibleItemCount(1);
for (String item : sampleValueList) {
fieldValue.addItem(item);
}
if (selectedValue == null) {
fieldValue.setItemSelected(0, true);
} else {
fieldValue.setItemSelected(sampleValueList.indexOf(selectedValue), true);
}
return fieldValue;
}
示例3: addMultipleSelectListBox
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
/**
* To add Multiple Select List Box.
*
* @param row int
* @param sampleValueList List<String>
* @param MAX_VISIBLE_ITEM_COUNT int
* @param value String
* @return ListBox
*/
public ListBox addMultipleSelectListBox(int row, List<String> sampleValueList, int MAX_VISIBLE_ITEM_COUNT, String value) {
ListBox fieldValue = new ListBox(true);
fieldValue.setVisibleItemCount(MAX_VISIBLE_ITEM_COUNT);
for (String item : sampleValueList) {
fieldValue.addItem(item);
}
String[] selectedValue = value.split(";");
for (String string : selectedValue) {
fieldValue.setItemSelected(sampleValueList.indexOf(string), true);
}
return fieldValue;
}
示例4: addDropDown
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
/**
* To add drop down.
*
* @param row int
* @param sampleValueList List<String>
* @param selectedValue String
* @return ListBox
*/
public ListBox addDropDown(int row, List<String> sampleValueList, String selectedValue) {
ListBox fieldValue = new ListBox();
fieldValue.setVisibleItemCount(1);
for (String item : sampleValueList) {
fieldValue.addItem(item);
}
fieldValue.setItemSelected(sampleValueList.indexOf(selectedValue), true);
return fieldValue;
}
示例5: addDropDown
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
public ListBox addDropDown(String fieldOptionValueList, String value) {
ListBox fieldValue = new ListBox();
fieldValue.setVisibleItemCount(1);
String[] selectedValue = fieldOptionValueList.split(";");
List<String> selectedValueList = Arrays.asList(selectedValue);
for (String item : selectedValueList) {
if (!item.trim().isEmpty()) {
fieldValue.addItem(item);
}
}
if (value != null && !value.isEmpty()) {
fieldValue.setItemSelected(selectedValueList.indexOf(value), true);
}
return fieldValue;
}
示例6: reload
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
public void reload(String history) {
if (history == null) return;
if (history.indexOf('&') >= 0)
history = history.substring(0, history.indexOf('&'));
if (history.isEmpty()) return;
String[] params = history.split(":");
String id = params[0];
PointInTimeDataReportsInterface.Report rpt = null;
for (int i = 0; i < iReports.size(); i++) {
PointInTimeDataReportsInterface.Report q = iReports.get(i);
if (id.equals(q.getId())) {
rpt = q;
iReportSelector.getWidget().setSelectedIndex(1 + i);
queryChanged();
break;
}
}
if (rpt == null) return;
int idx = 1;
for (int i = 0; i < iParameters.size(); i++) {
PointInTimeDataReportsInterface.Parameter parameter = iParameters.get(i);
if (rpt.parametersContain(parameter.getType())) {
String param = params[idx++];
if (param == null || param.isEmpty()) continue;
if (parameter.isTextField()) {
TextBox text = ((UniTimeWidget<TextBox>)iForm.getWidget(3 + i, 1)).getWidget();
text.setText(param);
} else {
ListBox list = ((UniTimeWidget<ListBox>)iForm.getWidget(3 + i, 1)).getWidget();
if (list.isMultipleSelect()) {
for (int j = 0; j < list.getItemCount(); j++) {
String value = list.getValue(j);
boolean contains = false;
for (String o: param.split(",")) if (o.equals(value)) { contains = true; break; }
list.setItemSelected(j, contains);
}
} else {
for (int j = 1; j < list.getItemCount(); j++) {
if (list.getValue(j).equals(param)) {
list.setSelectedIndex(j); break;
}
}
}
}
}
}
iLastSort = Integer.parseInt(params[idx++]);
execute();
}