Java Code Examples for com.google.gwt.user.client.ui.ListBox#getSelectedIndex()
The following examples show how to use
com.google.gwt.user.client.ui.ListBox#getSelectedIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaTwinColSelectWidget.java From cuba with Apache License 2.0 | 6 votes |
protected void updateListBox(List<JsonObject> items, ListBox listBox, BiConsumer<ListBox, List<JsonObject>> updateTask) { List<String> selectedItems = null; int selectedIdx = listBox.getSelectedIndex(); int itemsCount = listBox.getItemCount(); if (selectedIdx >= 0) { selectedItems = new ArrayList<>(); for (int i = selectedIdx; i < itemsCount; i++) { selectedItems.add(listBox.getItemText(i)); } } updateTask.accept(listBox, items); if (selectedItems != null) { // re-set selection for (int i = 0; i < itemsCount; i++) { String item = listBox.getItemText(i); listBox.setItemSelected(i, selectedItems.contains(item)); } } }
Example 2
Source File: Toolbar.java From djvu-html5 with GNU General Public License v2.0 | 6 votes |
protected void zoomSelectionChanged() { if (pageLayout == null) return; ListBox zoomSelection = zoomPanel.selection; int index = zoomSelection.getSelectedIndex(); if (index < zoomOptions.size()) { pageLayout.setZoom(zoomOptions.get(index)); } else { switch (index - zoomOptions.size()) { case 0: pageLayout.zoomToFitWidth(); break; case 1: pageLayout.zoomToFitPage(); break; default: throw new RuntimeException(); } } zoomPanel.textBox.setText(zoomSelection.getSelectedItemText()); zoomSelection.setFocus(false); }
Example 3
Source File: EventAdd.java From unitime with Apache License 2.0 | 5 votes |
@Override public List<RelatedObjectInterface> getValue() { List<RelatedObjectInterface> objects = new ArrayList<RelatedObjectInterface>(); for (int row = 1; row < getRowCount(); row ++) { CourseRelatedObjectLine line = getData(row); ListBox subject = (ListBox)getWidget(row, 0); RelatedObjectLookupRpcResponse rSubject = (subject.getSelectedIndex() < 0 ? null : line.getSubject(subject.getValue(subject.getSelectedIndex()))); ListBox course = (ListBox)getWidget(row, 1); RelatedObjectLookupRpcResponse rCourse = (course.getSelectedIndex() < 0 ? null : line.getCourse(course.getValue(course.getSelectedIndex()))); ListBox subpart = (ListBox)getWidget(row, 2); RelatedObjectLookupRpcResponse rSubpart = (subpart.getSelectedIndex() < 0 ? null : line.getSubpart(subpart.getValue(subpart.getSelectedIndex()))); ListBox clazz = (ListBox)getWidget(row, 3); RelatedObjectLookupRpcResponse rClazz = (clazz.getSelectedIndex() < 0 ? null : line.getClass(clazz.getValue(clazz.getSelectedIndex()))); if (rClazz != null && rClazz.getRelatedObject() != null) { objects.add(rClazz.getRelatedObject()); continue; } if (rSubpart != null && rSubpart.getRelatedObject() != null) { objects.add(rSubpart.getRelatedObject()); continue; } if (rCourse != null && rCourse.getRelatedObject() != null) { objects.add(rCourse.getRelatedObject()); continue; } if (rSubject != null && rSubject.getRelatedObject() != null) { objects.add(rSubject.getRelatedObject()); continue; } } return objects; }
Example 4
Source File: Toolbar.java From djvu-html5 with GNU General Public License v2.0 | 5 votes |
public void setZoomOptions(List<Integer> newZoomOptions) { ListBox zoomSelection = zoomPanel.selection; int previousIndex = zoomSelection.getSelectedIndex(); zoomSelection.clear(); for (int i : newZoomOptions) { zoomSelection.addItem(i + "%"); } zoomSelection.addItem(DjvuContext.getString("label_fitWidth", "Fit width")); zoomSelection.addItem(DjvuContext.getString("label_fitPage", "Fit page")); if (previousIndex >= zoomOptions.size()) { // either "fit with" or "fit page" was selected zoomSelection.setSelectedIndex(newZoomOptions.size() + (zoomOptions.size() - previousIndex)); } else { int zoom = pageLayout != null ? pageLayout.getZoom() : 100; int newSelected = Arrays.binarySearch(newZoomOptions.toArray(), zoom, Collections.reverseOrder()); if (newSelected >= 0) { zoomSelection.setSelectedIndex(Math.min(newSelected, newZoomOptions.size() - 1)); zoomOptions = newZoomOptions; zoomSelectionChanged(); } else { zoomSelection.setSelectedIndex(-1); zoomOptions = newZoomOptions; } } zoomPanel.updateButtons(); }
Example 5
Source File: SingleListBox.java From gwt-traction with Apache License 2.0 | 4 votes |
/** * Utility function to get the current value. */ public static final String getSelectedValue(ListBox list) { int index = list.getSelectedIndex(); return (index >= 0) ? list.getValue(index) : null; }
Example 6
Source File: SingleListBox.java From gwt-traction with Apache License 2.0 | 4 votes |
/** * Utility function to get the current text. */ public static final String getSelectedText(ListBox list) { int index = list.getSelectedIndex(); return (index >= 0) ? list.getItemText(index) : null; }