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

The following examples show how to use com.google.gwt.user.client.ui.ListBox#getValue() . 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
protected static Set<String> moveSelectedItems(ListBox source, ListBox target) {
    final boolean[] sel = getSelectionBitmap(source);
    final Set<String> movedItems = new HashSet<>();
    for (int i = 0; i < sel.length; i++) {
        if (sel[i]) {
            final int optionIndex = i
                    - (sel.length - source.getItemCount());
            movedItems.add(source.getValue(optionIndex));

            // Move selection to another column
            final String text = source.getItemText(optionIndex);
            final String value = source.getValue(optionIndex);
            target.addItem(text, value);
            target.setItemSelected(target.getItemCount() - 1, true);
            source.removeItem(optionIndex);
        }
    }

    target.setFocus(true);

    return movedItems;
}
 
Example 2
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 3
Source File: CourseNumbersSuggestBox.java    From unitime with Apache License 2.0 6 votes vote down vote up
private String getConfiguration() {
	String conf = iConfiguration;
	for (MatchResult matcher = iRegExp.exec(conf); matcher != null; matcher = iRegExp.exec(conf)) {
		Element element = DOM.getElementById(matcher.getGroup(1));
		String value = "";
		if ("select".equalsIgnoreCase(element.getTagName())) {
			ListBox list = ListBox.wrap(element);
			for (int i = 0; i < list.getItemCount(); i++) {
				if (list.isItemSelected(i))
					value += (value.isEmpty() ? "" : ",") + list.getValue(i);
			}
		} else if ("input".equalsIgnoreCase(element.getTagName())) {
			TextBox text = TextBox.wrap(element);
			value = text.getText();
		} else {
			Hidden hidden = Hidden.wrap(element);
			value = hidden.getValue();
		}
		conf = conf.replace("${" + matcher.getGroup(1) + "}", value);
	}
	return conf;
}
 
Example 4
Source File: PointInTimeDataReportsPage.java    From unitime with Apache License 2.0 4 votes vote down vote up
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();
}
 
Example 5
Source File: SingleListBox.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
/**
    * 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;
   }