Java Code Examples for com.google.gwt.user.client.ui.ListBox#clear()

The following examples show how to use com.google.gwt.user.client.ui.ListBox#clear() . 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 vote down vote up
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;
}
 
Example 2
Source File: Toolbar.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
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 3
Source File: Toolbar.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
public void setPageCount(int pagesCount) {
	this.pagesCount = pagesCount;
	ListBox pageSelection = pagePanel.selection;
	pageSelection.clear();
	for (int i = 1; i <= pagesCount; i++) {
		pageSelection.addItem(i + "");
	}
	pagePanel.updateButtons();
}