use of com.google.gwt.dom.client.InputElement in project che by eclipse.
the class CustomComboBox method resetSelectedIndex.
/**
* Ensures that no item is selected.
*/
private void resetSelectedIndex() {
if (getSelectedIndex() != -1) {
selectedIndex = -1;
NodeList<Element> selectionElements = optionsPanel.getElement().getElementsByTagName("input");
for (int pos = 0; pos < selectionElements.getLength(); pos++) {
InputElement inputElement = (InputElement) selectionElements.getItem(pos);
inputElement.setChecked(false);
}
}
}
use of com.google.gwt.dom.client.InputElement in project che by eclipse.
the class CustomComboBox 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;
currentInputElement.setValue(getItemText(index));
}
final InputElement inputElement = getListItemElement(index);
inputElement.setChecked(selected);
}
use of com.google.gwt.dom.client.InputElement in project che by eclipse.
the class CustomComboBox method getItemText.
/**
* Gets the text associated with the item at the specified index.
*
* @param index
* the index of the item whose text is to be retrieved
* @return the text associated with the item
* @throws IndexOutOfBoundsException
* if the index is out of range
*/
public String getItemText(int index) {
checkIndex(index);
final Element optionElement = (Element) optionsPanel.getElement().getChild(index);
final InputElement labelElement = (InputElement) optionElement.getElementsByTagName("input").getItem(0);
return labelElement.getValue();
}
use of com.google.gwt.dom.client.InputElement in project che by eclipse.
the class CustomListBox method getValue.
/**
* Gets the value associated with the item at a given index.
*
* @param index
* the index of the item to be retrieved
* @return the item's associated value
* @throws IndexOutOfBoundsException
* if the index is out of range
*/
public String getValue(int index) {
checkIndex(index);
final Element optionElement = (Element) optionsPanel.getElement().getChild(index);
final InputElement inputElement = (InputElement) optionElement.getElementsByTagName("input").getItem(0);
return inputElement.getValue();
}
use of com.google.gwt.dom.client.InputElement in project che by eclipse.
the class CustomListBox method insertItem.
/**
* Inserts an item into the list box.
*
* @param item
* the text of the item to be inserted.
* @param value
* the item's value.
*/
public void insertItem(String item, String value) {
//create new widget
final RadioButton radioButton = new RadioButton(optionsGroupName, item);
//remove the default gwt-RadioButton style
radioButton.removeStyleName("gwt-RadioButton");
//set value
final InputElement inputElement = (InputElement) radioButton.getElement().getElementsByTagName("input").getItem(0);
inputElement.removeAttribute("tabindex");
inputElement.setAttribute("value", value);
//set default state
if (defaultSelectedIndex > -1 && optionsPanel.getElement().getChildCount() == defaultSelectedIndex) {
inputElement.setChecked(true);
currentItemLabel.setInnerText(item);
}
//add to widget
optionsPanel.add(radioButton);
}
Aggregations