use of com.google.gwt.dom.client.InputElement in project che by eclipse.
the class CustomListBox 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);
}
use of com.google.gwt.dom.client.InputElement in project perun by CESNET.
the class PerunCheckboxCell method onBrowserEvent.
@Override
public void onBrowserEvent(Context context, Element parent, T value, NativeEvent event, ValueUpdater<T> valueUpdater) {
String type = event.getType();
boolean enterPressed = "keydown".equals(type) && event.getKeyCode() == KeyCodes.KEY_ENTER;
if ("change".equals(type) || enterPressed) {
InputElement input = parent.getFirstChild().cast();
Boolean isChecked = input.isChecked();
/*
* Toggle the value if the enter key was pressed and the cell
* handles selection or doesn't depend on selection. If the cell
* depends on selection but doesn't handle selection, then ignore
* the enter key and let the SelectionEventManager determine which
* keys will trigger a change.
*/
if (enterPressed && (handlesSelection() || !dependsOnSelection())) {
isChecked = !isChecked;
input.setChecked(isChecked);
}
/*
* Save the new value. However, if the cell depends on the
* selection, then do not save the value because we can get into an
* inconsistent state.
*/
if (((GeneralObject) value).isChecked() != isChecked && !dependsOnSelection()) {
setViewData(context.getKey(), isChecked);
} else {
clearViewData(context.getKey());
}
if (valueUpdater != null) {
((GeneralObject) value).setChecked(isChecked);
valueUpdater.update(value);
}
}
}
Aggregations