com.google.gwt.dom.client.InputElement Java Examples

The following examples show how to use com.google.gwt.dom.client.InputElement. 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: BaseCheckBox.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
protected BaseCheckBox(Element elem) {
    super(elem, CssName.GWT_CHECKBOX);

    inputElem = InputElement.as(DOM.createInputCheck());
    labelElem = Document.get().createLabelElement();

    getElement().appendChild(inputElem);
    getElement().appendChild(labelElem);

    String uid = DOM.createUniqueId();
    inputElem.setPropertyString("id", uid);
    labelElem.setHtmlFor(uid);

    directionalTextHelper = new DirectionalTextHelper(labelElem, true);

    // Accessibility: setting tab index to be 0 by default, ensuring element
    // appears in tab sequence. FocusWidget's setElement method already
    // calls setTabIndex, which is overridden below. However, at the time
    // that this call is made, inputElem has not been created. So, we have
    // to call setTabIndex again, once inputElem has been created.
    setTabIndex(0);
}
 
Example #2
Source File: ReturnsCustomMocks.java    From gwtmockito with Apache License 2.0 6 votes vote down vote up
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
  // Make JavaScriptObject.cast work in most cases by forcing it to return the underlying mock
  // instead of a new mock of type JavaScriptObject. This allows cast to be used in situations
  // that don't violate the Java type system, but not in situations that do (even though
  // javascript would allow them).
  String methodName = invocation.getMethod().getName();
  if (invocation.getMock() instanceof JavaScriptObject && methodName.equals("cast")) {
    return invocation.getMock();
  } else if (invocation.getMock() instanceof Element && methodName.equals("getTagName")) {
    String className = invocation.getMock().getClass().getSimpleName();
    return className.substring(0, className.indexOf("Element")).toLowerCase();
  } else if (invocation.getMock() instanceof InputElement && methodName.equals("getType")) {
    return "text";
  } else {
    return super.answer(invocation);
  }
}
 
Example #3
Source File: RadioButton.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public void onAttributeModified(ContentElement element, String name, String oldValue,
    String newValue) {
  if (GROUP.equalsIgnoreCase(name)) {
    InputElement inputElement = InputElement.as(element.getImplNodelet());
    inputElement.setName(element.getEditorUniqueString() + newValue);
  } else if (ContentElement.NAME.equalsIgnoreCase(name)) {
    EditorStaticDeps.logger.trace().log("myname: " + element.getName());
    element.getImplNodelet().setId(element.getEditorUniqueString() + newValue);
  }

  String groupName = element.getAttribute(GROUP);
  String elementName = element.getName();
  if (groupName != null && elementName != null) {
    EditorStaticDeps.logger.trace().log("myname: " + element.getName());
    ContentElement group = getGroup(element);
    if (group != null) {
      EditorStaticDeps.logger.trace().log(
          "selected: " + group.getAttribute(CheckConstants.VALUE));
      if (elementName != null && elementName.equals(group.getAttribute(CheckConstants.VALUE))) {
        setImplChecked(element, true);
      }
    } else {
      EditorStaticDeps.logger.trace().log("Cannot find associated group");
    }
  }
}
 
Example #4
Source File: CheckBox.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  InputElement inputElem = Document.get().createCheckInputElement();
  inputElem.setClassName(CheckConstants.css.check());

  // Wrap in non-editable span- Firefox does not fire events for checkboxes
  // inside contentEditable region.
  SpanElement nonEditableSpan = Document.get().createSpanElement();
  DomHelper.setContentEditable(nonEditableSpan, false, false);
  nonEditableSpan.appendChild(inputElem);

  return nonEditableSpan;
}
 
Example #5
Source File: RadioButton.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  // Note(user): IE insists that the input element's name attribute is
  // set at creation to correctly group radio buttons
  InputElement radioInputElement =
      Document.get().createRadioInputElement("xx");
  radioInputElement.setClassName(CheckConstants.css.radio());
  radioInputElement.setTabIndex(0);
  return radioInputElement;
}
 
Example #6
Source File: TableSelecter.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
TDSelecter() {
	super(TableCellElement.TAG_TD);
	if (TableSelecter.this.singleSelection) {
		this.inputElem = InputElement.as(DOM.createInputRadio(TableSelecter.this.groupId));
	} else {
		this.inputElem = InputElement.as(DOM.createInputCheck());
	}
	this.getElement().appendChild(this.inputElem);
}
 
Example #7
Source File: RadioButton.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public void onAttributeModified(ContentElement element, String name, String oldValue,
    String newValue) {
  if (GROUP.equalsIgnoreCase(name)) {
    InputElement inputElement = InputElement.as(element.getImplNodelet());
    inputElement.setName(element.getEditorUniqueString() + newValue);
  } else if (ContentElement.NAME.equalsIgnoreCase(name)) {
    EditorStaticDeps.logger.trace().log("myname: " + element.getName());
    element.getImplNodelet().setId(element.getEditorUniqueString() + newValue);
  }

  String groupName = element.getAttribute(GROUP);
  String elementName = element.getName();
  if (groupName != null && elementName != null) {
    EditorStaticDeps.logger.trace().log("myname: " + element.getName());
    ContentElement group = getGroup(element);
    if (group != null) {
      EditorStaticDeps.logger.trace().log(
          "selected: " + group.getAttribute(CheckConstants.VALUE));
      if (elementName != null && elementName.equals(group.getAttribute(CheckConstants.VALUE))) {
        setImplChecked(element, true);
      }
    } else {
      EditorStaticDeps.logger.trace().log("Cannot find associated group");
    }
  }
}
 
Example #8
Source File: Password.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * TODO(danilatos): Have this be called by the central event routing, not the hack
 * dom listeners below?
 *
 * @param p
 */
public void handleTyping(ContentElement p) {
  isMutatingLocallyToMatchUserInput = true;
  try {
    p.getMutableDoc().setElementAttribute(p, "value",
        p.getImplNodelet().<InputElement>cast().getValue());
  } finally {
    isMutatingLocallyToMatchUserInput = false;
  }
}
 
Example #9
Source File: Password.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public void onAttributeModified(ContentElement element, String name, String oldValue,
    String newValue) {
  if (VALUE.equals(name) && !eventHandler.isMutatingLocallyToMatchUserInput) {
    element.getImplNodelet().<InputElement>cast().setValue(newValue);
  }
}
 
Example #10
Source File: Password.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public void onAttributeModified(ContentElement element, String name, String oldValue,
    String newValue) {
  if (VALUE.equals(name) && !eventHandler.isMutatingLocallyToMatchUserInput) {
    element.getImplNodelet().<InputElement>cast().setValue(newValue);
  }
}
 
Example #11
Source File: Password.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * TODO(danilatos): Have this be called by the central event routing, not the hack
 * dom listeners below?
 *
 * @param p
 */
public void handleTyping(ContentElement p) {
  isMutatingLocallyToMatchUserInput = true;
  try {
    p.getMutableDoc().setElementAttribute(p, "value",
        p.getImplNodelet().<InputElement>cast().getValue());
  } finally {
    isMutatingLocallyToMatchUserInput = false;
  }
}
 
Example #12
Source File: SingleValueTagsInput.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
public SingleValueTagsInput(final Collection<? extends Dataset<T>> datasets) {
    InputElement tagsInput = Document.get().createTextInputElement();
    tagsInput.setAttribute("data-role", "tagsinput");
    
    setElement(tagsInput);        
    
    setDatasets(datasets);
}
 
Example #13
Source File: RadioButton.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  // Note(user): IE insists that the input element's name attribute is
  // set at creation to correctly group radio buttons
  InputElement radioInputElement =
      Document.get().createRadioInputElement("xx");
  radioInputElement.setClassName(CheckConstants.css.radio());
  radioInputElement.setTabIndex(0);
  return radioInputElement;
}
 
Example #14
Source File: CheckBox.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  InputElement inputElem = Document.get().createCheckInputElement();
  inputElem.setClassName(CheckConstants.css.check());

  // Wrap in non-editable span- Firefox does not fire events for checkboxes
  // inside contentEditable region.
  SpanElement nonEditableSpan = Document.get().createSpanElement();
  DomHelper.setContentEditable(nonEditableSpan, false, false);
  nonEditableSpan.appendChild(inputElem);

  return nonEditableSpan;
}
 
Example #15
Source File: FocusableMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public void setAccessKey(final char key) {
    final Element element = uiObject.getElement();
    final String accessKey = Character.toString(key);

    if (AnchorElement.is(element)) {
        AnchorElement.as(element).setAccessKey(accessKey);
    } else if (ButtonElement.is(element)) {
        ButtonElement.as(element).setAccessKey(accessKey);
    } else if (InputElement.is(element)) {
        InputElement.as(element).setAccessKey(accessKey);
    }
}
 
Example #16
Source File: CubaOptionGroupWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void updateItemsSelection() {
    for (Widget w : panel) {
        if (w instanceof RadioButton) {
            Element input = w.getElement().getFirstChildElement();
            if (input instanceof InputElement) {
                boolean checked = ((InputElement) input).isDefaultChecked();
                ((InputElement) input).setChecked(checked);
            }
        }
    }
}
 
Example #17
Source File: AbstractInputBox.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public int getMaxLength() {
	return InputElement.as(this.input.getElement()).getMaxLength();
}
 
Example #18
Source File: ToggleSwitchBase.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
protected ToggleSwitchBase(InputElement element) {
    this.element = element;
    setElement(element);
}
 
Example #19
Source File: RadioButton.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the implNodelet as an InputElement or null.
 */
public static InputElement getImplAsInputElement(ContentElement element) {
  return InputElement.as(element.getImplNodelet());
}
 
Example #20
Source File: GwtMockitoTest.java    From gwtmockito with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReturnTextAsType() {
  assertEquals("text", InputElement.as(Document.get().createTextInputElement()).getType());
}
 
Example #21
Source File: ToDoCell.java    From blog with MIT License 4 votes vote down vote up
/**
 * Commits the changes in text value to the ToDoItem
 */
private void commitEdit(Element parent, ToDoItem value) {
	InputElement input = getInputElement(parent);
	value.setTitle(input.getValue());
	eventBus.fireEvent(new ToDoUpdatedEvent(value));
}
 
Example #22
Source File: ToDoCell.java    From blog with MIT License 4 votes vote down vote up
/**
 * Get the input element in edit mode.
 */
private InputElement getInputElement(Element parent) {
	return parent.getFirstChild().getFirstChild().<InputElement> cast();
}
 
Example #23
Source File: CheckBox.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
private void updateCheckboxDom(ContentElement checkbox, boolean isChecked) {
  Element implNodelet = checkbox.getImplNodelet();
  InputElement checkboxElem = (InputElement) implNodelet.getFirstChild();
  checkboxElem.setChecked(isChecked);
}
 
Example #24
Source File: BinaryData.java    From requestor with Apache License 2.0 4 votes vote down vote up
private static native JavaScriptObject getFile(InputElement input, int index) /*-{
   return input.files[index];
}-*/;
 
Example #25
Source File: InputFile.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public UploadForm destroy() {
	InputElement.as(this.fileUpload.getElement()).setValue(null);
	this.handlerRegistrations.removeHandler();
	this.formPanel.removeFromParent();
	return null;
}
 
Example #26
Source File: AggregationInputFieldInfo.java    From cuba with Apache License 2.0 4 votes vote down vote up
public AggregationInputFieldInfo(String oldValue, String columnKey, InputElement inputElement, TableCellElement td) {
    this(oldValue, columnKey, inputElement);
    this.td = td;
}
 
Example #27
Source File: AbstractInputBox.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setMaxLength(int maxLength) {
	InputElement.as(this.input.getElement()).setMaxLength(maxLength);
}
 
Example #28
Source File: CharacterBox.java    From dashbuilder with Apache License 2.0 4 votes vote down vote up
private InputElement getInputElement() {
    return getElement().cast();
}
 
Example #29
Source File: RadioButton.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the implNodelet as an InputElement or null.
 */
public static InputElement getImplAsInputElement(ContentElement element) {
  return InputElement.as(element.getImplNodelet());
}
 
Example #30
Source File: CheckBox.java    From swellrt with Apache License 2.0 4 votes vote down vote up
private void updateCheckboxDom(ContentElement checkbox, boolean isChecked) {
  Element implNodelet = checkbox.getImplNodelet();
  InputElement checkboxElem = (InputElement) implNodelet.getFirstChild();
  checkboxElem.setChecked(isChecked);
}