本文整理匯總了Java中com.google.gwt.dom.client.InputElement.setChecked方法的典型用法代碼示例。如果您正苦於以下問題:Java InputElement.setChecked方法的具體用法?Java InputElement.setChecked怎麽用?Java InputElement.setChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.dom.client.InputElement
的用法示例。
在下文中一共展示了InputElement.setChecked方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: insertItem
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* 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);
currentInputElement.setValue("");
}
// add to widget
optionsPanel.add(radioButton);
}
示例2: insertItem
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* 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);
}
示例3: setSelectedIndex
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* 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);
}
示例4: select
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* 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("");
}
示例5: setItemSelected
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* 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);
}
示例6: setSelectedIndex
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* 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);
}
示例7: resetSelectedIndex
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/** 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);
}
}
}
示例8: setItemSelected
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* 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);
}
示例9: setCheckBoxState
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
private void setCheckBoxState(Path nodePath, InputElement checkBoxInputElement) {
if (indeterminate.contains(nodePath)) {
checkBoxInputElement.setId(checkBoxInputElement.getId() + "-indeterminate");
setIndeterminate(checkBoxInputElement);
} else if (!unselected.contains(nodePath)) {
checkBoxInputElement.setChecked(true);
checkBoxInputElement.setId(checkBoxInputElement.getId() + "-checked");
} else {
checkBoxInputElement.setId(checkBoxInputElement.getId() + "-unchecked");
}
}
示例10: disableInputs
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* Disables all the provided inputEls
* @param inputEls
*/
public static void disableInputs(final Collection<InputElement> inputEls) {
if (CollectionUtils.isNullOrEmpty(inputEls)) return;
for (InputElement inputEl : inputEls) {
inputEl.setChecked(false); // ?� this is NOT the same as getValue
inputEl.setDisabled(true);
}
}
示例11: enableInputs
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
/**
* Enables all the provided inputEls
* @param inputEls
*/
public static void enableInputs(final Collection<InputElement> inputEls) {
if (CollectionUtils.isNullOrEmpty(inputEls)) return;
for (InputElement inputEl : inputEls) {
inputEl.setChecked(true); // ?� this is NOT the same as getValue
inputEl.setDisabled(false);
}
}
示例12: onBrowserEvent
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
@Override
public void onBrowserEvent(Context context, Element elem, T object, NativeEvent event) {
if (BrowserEvents.CHANGE.equals(event.getType())) {
InputElement input = elem.getFirstChild().cast();
input.setChecked(!input.isChecked());
}
}
示例13: onBrowserEvent
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
@Override
public void onBrowserEvent( final Context context,
final Element parent,
final Boolean value,
final NativeEvent event,
final ValueUpdater<Boolean> valueUpdater ) {
String type = event.getType();
boolean enterPressed = BrowserEvents.KEYDOWN.equals( type )
&& event.getKeyCode() == KeyCodes.KEY_ENTER;
if ( BrowserEvents.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 ( value != isChecked && !dependsOnSelection() ) {
setViewData( context.getKey(), isChecked );
} else {
clearViewData( context.getKey() );
}
if ( valueUpdater != null ) {
valueUpdater.update( isChecked );
}
}
}
示例14: updateCheckboxDom
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
private void updateCheckboxDom(ContentElement checkbox, boolean isChecked) {
Element implNodelet = checkbox.getImplNodelet();
InputElement checkboxElem = (InputElement) implNodelet.getFirstChild();
checkboxElem.setChecked(isChecked);
}
示例15: onBrowserEvent
import com.google.gwt.dom.client.InputElement; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void onBrowserEvent(Context context, Element parent, Boolean value,
NativeEvent event, ValueUpdater<Boolean> 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();
Object key = context.getKey();
if ( isEnabledPredicate != null && !isEnabledPredicate.isEnabled((T) key)) {
// disabled checkbox -- no changes!
return;
}
/*
* Toggle the value if the enter key was pressed; this brings
* the key-press event path in line with a mouse-click event path.
*/
if (enterPressed) {
isChecked = !isChecked;
input.setChecked(isChecked);
}
/*
* See if this is a valid action for this checkbox.
*/
boolean changed = true;
if ( validationPredicate != null && !validationPredicate.isValid(isChecked, (T) key)) {
isChecked = !isChecked;
changed = false;
}
/*
* Save the new value.
*/
if (value != isChecked) {
setViewData(context.getKey(), isChecked);
} else {
clearViewData(context.getKey());
}
// redraw our parent with the value we ended up with...
SafeHtmlBuilder sb = new SafeHtmlBuilder();
render(context, isChecked, sb);
parent.setInnerHTML(sb.toSafeHtml().asString());
// apparently the element never gains focus...
if ( changed ) {
// do value-change action...
if (valueUpdater != null) {
valueUpdater.update(isChecked);
}
}
}
}