本文整理汇总了Java中com.google.gwt.user.client.ui.ListBox.addItem方法的典型用法代码示例。如果您正苦于以下问题:Java ListBox.addItem方法的具体用法?Java ListBox.addItem怎么用?Java ListBox.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.ListBox
的用法示例。
在下文中一共展示了ListBox.addItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: days
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private void days(ListBox day, int year, int month) {
day.clear();
int lo_year = lo.getYear();
int hi_year = hi.getYear();
int lo_month = lo.getMonthOfYear();
int hi_month = hi.getMonthOfYear();
int start = 1;
int end = maxDays(year, month);
if ( lo_year == year && lo_month == month ) {
start = lo.getDayOfMonth();
end = maxDays(year, month);
}
// If it starts and ends in the same month replace with the day of the high month.
if ( hi_year == year && hi_month == month ) {
end = hi.getDayOfMonth();
}
for ( int i = start; i <= end; i++) {
day.addItem(GeoUtil.format_two(i), GeoUtil.format_two(i));
}
}
示例2: 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;
}
示例3: addVolumeMenuItems
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private void addVolumeMenuItems( ListBox volumeMenu )
{
volumeMenu.addItem( "0%", "0" );
volumeMenu.addItem( "5%", "5" );
volumeMenu.addItem( "10%", "10" );
volumeMenu.addItem( "15%", "15" );
volumeMenu.addItem( "20%", "20" );
volumeMenu.addItem( "25%", "25" );
volumeMenu.addItem( "30%", "30" );
volumeMenu.addItem( "35%", "35" );
volumeMenu.addItem( "40%", "40" );
volumeMenu.addItem( "45%", "45" );
volumeMenu.addItem( "50%", "50" );
volumeMenu.addItem( "55%", "55" );
volumeMenu.addItem( "60%", "60" );
volumeMenu.addItem( "65%", "65" );
volumeMenu.addItem( "70%", "70" );
volumeMenu.addItem( "75%", "75" );
volumeMenu.addItem( "80%", "80" );
volumeMenu.addItem( "85%", "85" );
volumeMenu.addItem( "90%", "90" );
volumeMenu.addItem( "95%", "95" );
volumeMenu.addItem( "100%", "100" );
}
示例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
* @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;
}
示例5: addSelectedModule
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private void addSelectedModule() {
ListBox fromList = view.getMultipleSelectTwoSidedListBox().getLeftHandSideListBox();
List<Integer> selectedIndexes = view.getMultipleSelectTwoSidedListBox().getAllSelectedIndexes(fromList);
for (Integer selectedIndex : selectedIndexes) {
if (selectedIndex != -1) {
String selectedValue = fromList.getItemText(selectedIndex);
String selectedValueKey = BatchClassManagementConstants.EMPTY_STRING;
ListBox toList = view.getMultipleSelectTwoSidedListBox().getRightHandSideListBox();
Map<String, String> moduleIdentifierToNameMap = view.getMultipleSelectTwoSidedListBox()
.getAllValuesMapFromList(toList);
do {
selectedValueKey = BatchClassManagementConstants.NEW + newIdentifier++;
} while (moduleIdentifierToNameMap.containsKey(selectedValueKey));
toList.addItem(selectedValue, selectedValueKey);
int newIndex = toList.getItemCount() - 1;
toList.getElement().getElementsByTagName("option").getItem(newIndex).setTitle(selectedValue);
}
}
}
示例6: setRunes
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private void setRunes(Anchor anchor2, ListBox list2, ActiveSkill skill) {
list2.clear();
if (skill != null) {
for (Rune r : skill.getRunes()) {
list2.addItem(r.getLongName(), r.name());
}
} else {
list2.addItem("None", Rune.None.name());
}
list2.setSelectedIndex(0);
setRuneAnchor(skill, anchor2, Rune.None);
}
示例7: add
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
@SafeVarargs
public static <E extends Enum<E>> void add (boolean allowNone,
ListBox cboPosition, Class<E> e, E... exclude) {
HashSet<E> s = new HashSet<>(Arrays.asList(exclude));
if (allowNone) {
cboPosition.addItem("None", "");
}
for (E v : e.getEnumConstants()) {
if (!s.contains(v)) {
cboPosition.addItem(v.toString());
}
}
}
示例8: makeTemplatesMenu
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
/**
* Creates a drop down menu for selecting Template repositories.
* @return the drop down menu of repository Urls.
*/
private ListBox makeTemplatesMenu() {
final ListBox templatesMenu = new ListBox();
templatesMenu.addItem(MESSAGES.templateUploadNewUrlCaption());
templatesMenu.addItem(MIT_TEMPLATES);
for (int k = 0; k < dynamicTemplateUrls.size(); k++) { // Dynamically added Urls
templatesMenu.addItem(dynamicTemplateUrls.get(k));
}
templatesMenu.setSelectedIndex(MIT_TEMPLATES_INDEX);
templatesMenu.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
int selectedIndex = templatesMenu.getSelectedIndex();
if (selectedIndex == 0) {
templatesMenu.setSelectedIndex(lastSelectedIndex);
usingExternalTemplate = true; // MIT templates at index 1
removeButton.setVisible(false);
new InputTemplateUrlWizard(instance).center(); // This will do a callback
} else if (selectedIndex == 1) {
removeButton.setVisible(false); lastSelectedIndex = selectedIndex;
usingExternalTemplate = false; // MIT templates at index 1
templateHostUrl = "";
retrieveSelectedTemplates(templatesMenu.getValue(selectedIndex)); // may do callback
} else {
removeButton.setVisible(true); lastSelectedIndex = selectedIndex;
usingExternalTemplate = true; // MIT templates at index 1
templateHostUrl = templatesMenu.getValue(selectedIndex);
retrieveSelectedTemplates(templatesMenu.getValue(selectedIndex)); // may do callback
}
}
});
templatesMenu.setVisibleItemCount(1); // Turns menu into a drop-down list).
return templatesMenu;
}
示例9: MockSpinner
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
/**
* Creates a new MockSpinner component.
*
* @param editor editor of source file the component belongs to
*/
public MockSpinner(SimpleEditor editor) {
super(editor, TYPE, images.spinner());
// Initialize mock label UI
spinnerWidget = new ListBox();
spinnerWidget.addItem(MESSAGES.MockSpinnerAddItems());
spinnerWidget.setStylePrimaryName("ode-SimpleMockComponent");
spinnerWidget.addStyleName("spinnerComponentStyle");
initComponent(spinnerWidget);
refreshForm();
}
示例10: copyListItemsToListBox
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
static public void copyListItemsToListBox(ListBox lb) {
if (lb == null)
return;
for (int i=0; i<EndpointTypesListItems.length; i++) {
lb.addItem(EndpointTypesListItems[i][1], EndpointTypesListItems[i][0]);
}
}
示例11: minutes
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private void minutes(ListBox mins, int start_minute, int end_minute) {
mins.clear();
for (int min = start_minute; min <= end_minute; min++) {
mins.addItem(GeoUtil.format_two(min), GeoUtil.format_two(min));
}
}
示例12: months
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private void months(ListBox month, int year) {
month.clear();
int lo_year = lo.getYear();
int hi_year = hi.getYear();
int start = 1;
int end = 12;
if ( lo_year == year ) {
start = lo.getMonthOfYear();
}
if ( hi_year == year ) {
end = hi.getMonthOfYear();
}
// DateTime startDate = new DateTime(year, start, 1, 0, 0, DateTimeZone.UTC).withChronology(chrono);
// DateTime endDate = new DateTime(year, end, 1, 0, 0, DateTimeZone.UTC).withChronology(chrono);
DateTime startDate = lo.withYear(year).withMonthOfYear(start).withDayOfMonth(1).withHourOfDay(0).withMinuteOfHour(0);
DateTime endDate = hi.withYear(year).withMonthOfYear(end).withDayOfMonth(1).withHourOfDay(0).withMinuteOfHour(0);
while (startDate.isBefore(endDate.getMillis()) || startDate.equals(endDate)) {
month.addItem(monthFormat.print(startDate.getMillis()));
startDate = startDate.plusMonths(1);
}
}
示例13: years
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
private void years(DateTime lo, DateTime hi, ListBox year) {
year.clear();
int start = lo.getYear();
int end = hi.getYear();
for ( int y = start; y <= end; y++ ) {
year.addItem(GeoUtil.format_four(y), GeoUtil.format_four(y));
}
}
示例14: onModuleLoad
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
public void onModuleLoad() {
PublishSubject<String> query = PublishSubject.create();
TextBox text = new TextBox(); RootPanel.get().add(text);
text.addValueChangeHandler(e -> query.onNext(e.getValue()));
Button search = new Button("search"); RootPanel.get().add(search);
search.addClickHandler(e -> query.onNext(text.getValue()));
ListBox url = new ListBox(); RootPanel.get().add(url);
url.addItem(NOMINATIM_OPENSTREETMAP);
url.addItem("http://localhost:8080/");
url.addChangeHandler(e -> query.onNext(text.getValue()));
FlowPanel results = new FlowPanel(); RootPanel.get().add(results);
// remember last selected server
Storage storage = Storage.getLocalStorageIfSupported();
if (storage != null) {
try {
url.setSelectedIndex(Integer.valueOf(storage.getItem("nominatim.url")));
} catch (Exception ignore) {}
url.addChangeHandler(c -> storage.setItem("nominatim.url", Integer.toString(url.getSelectedIndex())));
}
// on each tick, re-configure root resource and fire new request
query.switchMap(q -> {
results.clear();
if (q == null || q.isEmpty()) return Observable.empty();
Nominatim nominatim = new Nominatim_RestServiceModel(() -> osm(url.getSelectedItemText()));
return nominatim.search(q, "json").doOnNext(n -> results.add(new Label(
"[" + (int) (n.importance * 10.) + "] " + n.display_name + " (" + n.lon + "," + n.lat + ")")));
}).retry((cnt, err) -> {
GWT.log("request error: " + err, err); return true;
}).subscribe();
// fires initial search
text.setValue("Málaga,España", true);
}
示例15: buildPanel
import com.google.gwt.user.client.ui.ListBox; //导入方法依赖的package包/类
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
addLabel();
ListBox labelsLBox = new ListBox();
labelsLBox.addItem("Add label", "0");
labelsLBox.addItem("Set font", "1");
labelsLBox.addItem("Set properties", "2");
labelsLBox.addItem("Offset label by distance", "3");
labelsLBox.addItem("Fade label by distance", "4");
labelsLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
ListBox source = (ListBox) event.getSource();
reset();
switch (source.getSelectedValue()) {
case "0": addLabel(); break;
case "1": setFont(); break;
case "2": setProperties(); break;
case "3": offsetByDistance(); break;
case "4": fadeByDistance(); break;
default: break;
}
}
});
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(labelsLBox, 20, 20);
contentPanel.add(new HTML("<p>Create Labels</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}