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