Search in sources :

Example 1 with InputElement

use of com.google.gwt.dom.client.InputElement in project che by eclipse.

the class CustomListBox method select.

/**
     * Selects an item with given text.
     *
     * @param text
     *          text of an item to be selected
     */
public void select(String text) {
    // uncheck previous value
    if (selectedIndex >= 0) {
        InputElement inputElement = getListItemElement(selectedIndex);
        inputElement.setChecked(false);
    }
    // find and select a new one
    if (text != null) {
        for (int i = 0; i < getItemCount(); i++) {
            if (text.equals(getItemText(i))) {
                setSelectedIndex(i);
                return;
            }
        }
    }
    // clear the selection
    selectedIndex = -1;
    currentItemLabel.setInnerText("");
}
Also used : InputElement(com.google.gwt.dom.client.InputElement)

Example 2 with InputElement

use of com.google.gwt.dom.client.InputElement in project che by eclipse.

the class CustomListBox method setItemSelected.

/**
     * Sets whether an individual list item is selected.
     *
     * @param index
     *         the index of the item to be selected or unselected
     * @param selected
     *         <code>true</code> to select the item
     */
public void setItemSelected(int index, boolean selected) {
    if (index < 0 || index >= getItemCount()) {
        return;
    }
    if (selected) {
        selectedIndex = index;
        currentItemLabel.setInnerText(getItemText(index));
    }
    final InputElement inputElement = getListItemElement(index);
    inputElement.setChecked(selected);
}
Also used : InputElement(com.google.gwt.dom.client.InputElement)

Example 3 with InputElement

use of com.google.gwt.dom.client.InputElement in project che by eclipse.

the class CustomListBox method setSelectedIndex.

/**
     * Sets the currently selected index.
     *
     * @param index
     *         the index of the item to be selected
     */
public void setSelectedIndex(int index) {
    if (index < 0) {
        return;
    }
    //set default index if not added options yet
    if (index >= getItemCount()) {
        defaultSelectedIndex = index;
        return;
    }
    selectedIndex = index;
    currentItemLabel.setInnerText(getItemText(index));
    InputElement inputElement = getListItemElement(index);
    inputElement.setChecked(true);
}
Also used : InputElement(com.google.gwt.dom.client.InputElement)

Example 4 with InputElement

use of com.google.gwt.dom.client.InputElement in project che by eclipse.

the class CustomComboBox method setValue.

/**
     * Sets the value associated with the item at a given index.
     *
     * @param index
     *         the index of the item to be set
     * @param value
     *         the item's new value
     * @throws IndexOutOfBoundsException
     *         if the index is out of range
     */
public void setValue(int index, String value) {
    checkIndex(index);
    final InputElement inputElement = getListItemElement(index);
    inputElement.setValue(value);
}
Also used : InputElement(com.google.gwt.dom.client.InputElement)

Example 5 with InputElement

use of com.google.gwt.dom.client.InputElement in project che by eclipse.

the class CustomComboBox method setSelectedIndex.

/**
     * Sets the currently selected index.
     *
     * @param index
     *         the index of the item to be selected
     */
public void setSelectedIndex(int index) {
    if (index < 0) {
        return;
    }
    //set default index if not added options yet
    if (index >= getItemCount()) {
        defaultSelectedIndex = index;
        return;
    }
    selectedIndex = index;
    currentInputElement.setValue(getItemText(index));
    final InputElement inputElement = getListItemElement(index);
    inputElement.setChecked(true);
}
Also used : InputElement(com.google.gwt.dom.client.InputElement)

Aggregations

InputElement (com.google.gwt.dom.client.InputElement)17 Element (com.google.gwt.dom.client.Element)5 LabelElement (com.google.gwt.dom.client.LabelElement)4 RadioButton (com.google.gwt.user.client.ui.RadioButton)2 FormElement (com.google.gwt.dom.client.FormElement)1