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

The following are top voted examples for showing how to use com.google.gwt.dom.client.InputElement. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: empiria.player   File: AccessibleCheckBox.java   Source Code and License 7 votes vote down vote up
protected AccessibleCheckBox(Element elem) {
    super(DOM.createSpan());
    inputElem = InputElement.as(elem);
    labelElem = Document.get().createLabelElement();

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

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

    // 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
Project: gwt-material   File: BaseCheckBox.java   Source Code and License 7 votes vote down vote up
protected BaseCheckBox(Element elem) {
    super(elem);

    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 3
Project: che   File: CheckBoxRender.java   Source Code and License 7 votes vote down vote up
@Override
public Element render(
    final Node node, final String domID, final Tree.Joint joint, final int depth) {
  // Initialize HTML elements.
  final Element rootContainer = super.render(node, domID, joint, depth);
  final Element nodeContainer = rootContainer.getFirstChildElement();
  final Element checkBoxElement = new CheckBox().getElement();
  final InputElement checkBoxInputElement =
      (InputElement) checkBoxElement.getElementsByTagName("input").getItem(0);

  final Path nodePath =
      node instanceof ChangedFileNode
          ? Path.valueOf(node.getName())
          : ((ChangedFolderNode) node).getPath();
  setCheckBoxState(nodePath, checkBoxInputElement);
  setCheckBoxClickHandler(nodePath, checkBoxElement, checkBoxInputElement.isChecked());

  // Paste check-box element to node container.
  nodeContainer.insertAfter(checkBoxElement, nodeContainer.getFirstChild());

  return rootContainer;
}
 
Example 4
Project: r01fb   File: TreeViewItem.java   Source Code and License 7 votes vote down vote up
@Override
public void prepareToAdoptChildren() {
	if (!this.hasChildren()) {	
		// BEFORE the item is prepared to adopt children, it's just like:
		//		<li>
		//			<input type="checkbox" class="expander" disabled>	<!-- input.expander DISABLED = no child -->
        //        	<span class="expander"></span>
        //        	<input type="checkbox" class="selection">
        //        	<!-- the widget --> <!-- if it's a text item: <label>Child Node 1</label> -->
		//			<!-- there's NO child items container -->
        //		</li>
		//
		// AFTER the item is prepared to adopt children, it's: 
		//		<li>
		//			<input type="checkbox" class="expander">			<!-- input.expander ENABLED = has child -->
        //        	<span class="expander"></span>
        //        	<input type="checkbox" class="selection">
        //        	<!-- the widget --> <!-- if it's a text item: <label>Child Node 1</label> -->
		//			<ul class='childContainer'>						 	<!-- child items container is present -->
		//				... here will come the child items 
		//			</ul>
        //		</li>
		// 
		// [1] - Create a child items container UL by cloning the BASE_INTERNAL_ELEM
		UListElement childContainerULElem = DOM.clone(BASE_CHILD_CONTAINER_ELEM,// an UL
										  			  true)						// deep cloning
										  	   .cast();
		// [2] - set the new UL as a child of the item (the LI)
		LIElement parentLI = this.getElement().cast();
		parentLI.appendChild(childContainerULElem);
		// [3] - Change the <input type="checkbox" class="expander"> status from DISABLED to ENABLED
		InputElement expanderINPUT = parentLI.getFirstChild().cast();	// from Node to Element
		expanderINPUT.setDisabled(false);
	} else {
		throw new IllegalStateException();
	}
}
 
Example 5
Project: gwtbootstrap3   File: InputToggleButtonGwt.java   Source Code and License 7 votes vote down vote up
@Override
public <T extends UIObject & HasEnabled> void checkEnabled(T button) {
    final Element label = button.getElement();
    final InputElement input = InputElement.as(label.getFirstChildElement());
    assertFalse(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
    assertFalse(input.isDisabled());
    button.setEnabled(false);
    assertTrue(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
    assertTrue(input.isDisabled());
    button.setEnabled(true);
    assertFalse(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
    assertFalse(input.isDisabled());
}
 
Example 6
Project: empiria.player   File: AccessibleCheckBox.java   Source Code and License 6 votes vote down vote up
/**
 * Replace the current input element with a new one. Preserves all state except for the name property, for nasty reasons related to radio button grouping.
 * (See implementation of {@link RadioButton#setName}.)
 *
 * @param elem the new input element
 */
protected void replaceInputElement(Element elem) {
    InputElement newInputElem = InputElement.as(elem);
    // Collect information we need to set
    int tabIndex = getTabIndex();
    boolean checked = getValue();
    boolean enabled = isEnabled();
    String formValue = getFormValue();
    String uid = inputElem.getId();
    String accessKey = inputElem.getAccessKey();
    int sunkEvents = Event.getEventsSunk(inputElem);

    // Clear out the old input element
    setEventListener(asOld(inputElem), null);

    getElement().replaceChild(newInputElem, inputElem);

    // Sink events on the new element
    Event.sinkEvents(elem, Event.getEventsSunk(inputElem));
    Event.sinkEvents(inputElem, 0);
    inputElem = newInputElem;

    // Setup the new element
    Event.sinkEvents(inputElem, sunkEvents);
    inputElem.setId(uid);
    if (!"".equals(accessKey)) {
        inputElem.setAccessKey(accessKey);
    }
    setTabIndex(tabIndex);
    setValue(checked);
    setEnabled(enabled);
    setFormValue(formValue);

    // Set the event listener
    if (isAttached()) {
        setEventListener(asOld(inputElem), this);
    }
}
 
Example 7
Project: gwt-react-examples   File: TodoItem.java   Source Code and License 6 votes vote down vote up
/**
 * Safely manipulate the DOM after updating the state when invoking
 * `props.onEdit()` in the `handleEdit` method above.
 * For more info refer to notes at https://facebook.github.io/react/docs/component-api.html#setstate
 * and https://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate
 */
public void componentDidUpdate(TodoItemProps prevProps, TodoItemProps prevState) {

    if (!prevProps.isEditing && props.isEditing) {
        InputElement inputEl = InputElement.as((InputElement)this.refs.get("editField"));
        inputEl.focus();
        inputEl.select();
    }
}
 
Example 8
Project: Wiab.pro   File: CheckBox.java   Source Code and License 6 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 9
Project: Wiab.pro   File: RadioButton.java   Source Code and License 6 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 10
Project: gwt-material   File: FocusableMixin.java   Source Code and License 6 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 11
Project: che   File: CustomComboBox.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 12
Project: che   File: CustomListBox.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 13
Project: che   File: CustomListBox.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 14
Project: che   File: CustomListBox.java   Source Code and License 6 votes vote down vote up
/**
 * 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("");
}
 
Example 15
Project: r01fb   File: TreeViewUtils.java   Source Code and License 6 votes vote down vote up
public static boolean isEventAssociatedWithItemExpander(final Element eventTarget) {
	boolean outIsExpander = false;
	if (InputElement.is(eventTarget)) { 
		InputElement inputEl = eventTarget.cast();
		if (inputEl.getType().equalsIgnoreCase("checkbox") 
		 && inputEl.getClassName().equalsIgnoreCase(EXPANDER_CLASS_NAME)) {
			outIsExpander = true;
		}
	}
	return outIsExpander;
}
 
Example 16
Project: r01fb   File: TreeViewUtils.java   Source Code and License 6 votes vote down vote up
public static boolean isEventAssociatedWithItemChecker(final Element eventTarget) {
	boolean outIsChecker = false;
	if (InputElement.is(eventTarget)) { 
		InputElement inputEl = eventTarget.cast();
		if (inputEl.getType().equalsIgnoreCase("checkbox") 
		 && inputEl.getClassName().equalsIgnoreCase(CHECKER_CLASS_NAME)) {
			outIsChecker = true;
		}
	}
	return outIsChecker;
}
 
Example 17
Project: fullmetalgalaxy   File: AppRoot.java   Source Code and License 6 votes vote down vote up
@Override
public void onPreviewNativeEvent(NativePreviewEvent p_event)
{
  if( p_event == null || p_event.getNativeEvent() == null
      || p_event.getNativeEvent().getEventTarget() == null )
  {
    return;
  }
  com.google.gwt.dom.client.Element elmt = com.google.gwt.dom.client.Element.as( p_event
      .getNativeEvent().getEventTarget() );
  if( elmt instanceof InputElement )
  {
    String type = ((InputElement)elmt).getType();
    if( type != null
        && (type.equals( "text" ) || type.equals( "password" ) || type.equals( "textarea" )) )
    {
      return;
    }
  }

  // don't preview event if user is editing someting in an input form
  m_previewListenerCollection.fireEventPreview( p_event );
}
 
Example 18
Project: platypus-js   File: NullableCheckBox.java   Source Code and License 6 votes vote down vote up
public NullableCheckBox(Element elem) {
	super(elem);
	inputElem = InputElement.as(elem);
	inputElem.setPropertyBoolean("indeterminate", true);		
	inputElem.getStyle().setVerticalAlign(VerticalAlign.MIDDLE);
	anchor.getStyle().setDisplay(Style.Display.INLINE_BLOCK);
	anchor.getStyle().setPosition(Style.Position.RELATIVE);
	anchor.getStyle().setHeight(100, Style.Unit.PCT);
	anchor.getStyle().setVerticalAlign(Style.VerticalAlign.MIDDLE);
	getElement().appendChild(anchor);
}
 
Example 19
Project: qafe-platform   File: QCheckBox.java   Source Code and License 6 votes vote down vote up
public QCheckBox(Element elem, String displaynamePosition) {
    inputElem = (InputElement) this.getElement().getChild(0);
    labelElem =  (LabelElement) this.getElement().getChild(1);
    if (displaynamePosition.equals(DISPLAYNAME_POSITION_LEFT)) {
    	getElement().appendChild(labelElem);
    	getElement().appendChild(inputElem);
    } else {
    	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 20
Project: putnami-web-toolkit   File: TableSelecter.java   Source Code and License 6 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 21
Project: gwtbootstrap3   File: FocusableMixin.java   Source Code and License 6 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 22
Project: gwtbootstrap3   File: InputToggleButtonGwt.java   Source Code and License 6 votes vote down vote up
@Override
public <T extends UIObject & HasName> void checkName(T button) {
    final String name = "name";
    final Element label = button.getElement();
    final InputElement input = InputElement.as(label.getFirstChildElement());
    button.setName(name);
    assertEquals(name, button.getName());
    assertEquals(name, input.getName());
}
 
Example 23
Project: gwtbootstrap3   File: InputToggleButtonGwt.java   Source Code and License 6 votes vote down vote up
@Override
public <T extends UIObject & HasFormValue> void checkFormValue(T button) {
    final String formValue = "formValue";
    final Element label = button.getElement();
    final InputElement input = InputElement.as(label.getFirstChildElement());
    button.setFormValue(formValue);
    assertEquals(formValue, button.getFormValue());
    assertEquals(formValue, input.getValue());
}
 
Example 24
Project: gwtbootstrap3   File: InputToggleButtonGwt.java   Source Code and License 6 votes vote down vote up
@Override
public <T extends UIObject & HasValue<Boolean>> void checkValue(T button) {
    final Element label = button.getElement();
    final InputElement input = InputElement.as(label.getFirstChildElement());
    button.setValue(true);
    assertTrue(button.getValue());
    assertTrue(input.isChecked());
    button.setValue(false);
    assertFalse(button.getValue());
    assertFalse(input.isChecked());
}
 
Example 25
Project: incubator-wave   File: RadioButton.java   Source Code and License 6 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 26
Project: gwtmockito   File: ReturnsCustomMocks.java   Source Code and License 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 27
Project: gwt-react-examples   File: StatefulExample.java   Source Code and License 5 votes vote down vote up
private void doChange(FormEvent event) {
    InputElement e = InputElement.as(event.target);
    String val = e.getValue();
    setState(State.make(val));
}
 
Example 28
Project: gwt-react-examples   File: StatefulExample.java   Source Code and License 5 votes vote down vote up
private void doChange(FormEvent event) {
    InputElement e = InputElement.as(event.target);
    String val = e.getValue();
    setState(State.make(val));
}
 
Example 29
Project: gwt-react-examples   File: StatefulExample.java   Source Code and License 5 votes vote down vote up
private void doChange(FormEvent event) {
    InputElement e = InputElement.as(event.target);
    String val = e.getValue();
    setState(State.make(val));
}
 
Example 30
Project: gwt-uploader   File: Uploader.java   Source Code and License 5 votes vote down vote up
private void openFileDialog(FileUpload fileUpload, boolean multipleFiles) {

    if (multipleFiles) {
      fileUpload.getElement().setAttribute("multiple", "true");
    } else {
      fileUpload.getElement().removeAttribute("multiple");
    }

    if (fileDialogStartHandler != null) {
      fileDialogStartHandler.onFileDialogStartEvent(new FileDialogStartEvent());
    }
    InputElement.as(fileUpload.getElement()).click();
  }
 
Example 31
Project: Wiab.pro   File: RadioButton.java   Source Code and License 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 32
Project: Wiab.pro   File: Password.java   Source Code and License 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 33
Project: Wiab.pro   File: Password.java   Source Code and License 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 34
Project: x-cure-chat   File: UserLoginDialogUI.java   Source Code and License 5 votes vote down vote up
private UserLoginDialogUI(){
	super( false, true, true, null);
	
	//Set the dialog's caption.
	this.setText( titlesI18N.userLoginDialogTitle() );
	
	//Set a style name so we can style it with CSS.
	this.setStyleName( CommonResourcesContainer.USER_DIALOG_STYLE_NAME );
	
       //Get a handle to the form and set its action to our jsni method
       form = FormPanel.wrap(Document.get().getElementById(LOGINFORM_ID), false);
       
       //Get the cancel button for text localization
       cancel = (ButtonElement) Document.get().getElementById(CANCELBUTTON_ID);
       cancel.setInnerText( getLeftButtonText() );
       
       //Get the submit button for text localization
       submit = (ButtonElement) Document.get().getElementById(LOGINBUTTON_ID);
       submit.setInnerText( getRightButtonText() );
       
       //Get the user login input
       userLoginInput = (InputElement) Document.get().getElementById(USERNAME_ID);
       
       //Get the user password input
       userPasswordInput = (InputElement) Document.get().getElementById(PASSWORD_ID);
       
	//Fill dialog with data
	populateDialog();
	
	//Enable the action buttons and hot key
	setLeftEnabled( true );
	setRightEnabled( true );
}
 
Example 35
Project: gwt-backbone   File: InputElementFloatAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public Float getData(final InputElement input, String attribute) throws ConversionException {
    String floatString = input.getValue().trim();
    if (!floatString.matches(REGEX_DECIMAL)) {
        String message = "Expected a floating point number, but was " + floatString;
        throw new ConversionException(message);
    }

    return Float.parseFloat(floatString);
}
 
Example 36
Project: gwt-backbone   File: InputElementIntegerAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public Integer getData(final InputElement input, String attribute) throws ConversionException {
    String integerString = input.getValue().trim();
    if (!integerString.matches(REGEX_INTEGER)) {
        String message = "Expected an integer, but was " + integerString;
        throw new ConversionException(message);
    }

    return Integer.parseInt(integerString);
}
 
Example 37
Project: gwt-backbone   File: InputElementDoubleAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public Double getData(final InputElement editText, String attribute) throws ConversionException {
    String doubleString = editText.getValue().trim();
    if (!doubleString.matches(REGEX_DECIMAL)) {
        String message = "Expected a floating point number, but was " + doubleString;
        throw new ConversionException(message);
    }

    return Double.parseDouble(doubleString);
}
 
Example 38
Project: che   File: CustomComboBox.java   Source Code and License 5 votes vote down vote up
/**
 * 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();
}
 
Example 39
Project: che   File: CustomComboBox.java   Source Code and License 5 votes vote down vote up
/**
 * 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();
}
 
Example 40
Project: che   File: CustomComboBox.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 41
Project: che   File: CustomComboBox.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 42
Project: che   File: CustomComboBox.java   Source Code and License 5 votes vote down vote up
/** 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);
    }
  }
}
 
Example 43
Project: che   File: CustomListBox.java   Source Code and License 5 votes vote down vote up
/**
 * 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();
}
 
Example 44
Project: che   File: CustomListBox.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 45
Project: che   File: KeyBindingManager.java   Source Code and License 5 votes vote down vote up
@Inject
public KeyBindingManager(ActionManager actionManager) {
  this.actionManager = actionManager;

  addScheme(new SchemeImpl(SCHEME_GLOBAL_ID, "Global"));
  addScheme(new SchemeImpl(SCHEME_ECLIPSE_ID, "Eclipse Scheme"));

  // TODO check user settings
  activeScheme = SCHEME_GLOBAL_ID;

  presentationFactory = new PresentationFactory();

  // Attach the listeners.
  final Element documentElement = Elements.getDocument().getDocumentElement();
  EventListener downListener =
      new EventListener() {
        @Override
        public void handleEvent(Event event) {
          SignalEvent signalEvent = SignalEventUtils.create(event, false);
          if (signalEvent == null) {
            return;
          }

          /*
          Temporary solution to prevent calling actions if focus is in input element.
          The problem in that, some actions, may be bound to Ctrl+C/X/V/Z or Delete so
          We should allow browser to process event natively instead of calling actions.
          Need to be reworked in nearest future. */
          final JavaScriptObject jso = (JavaScriptObject) event.getTarget();
          if (InputElement.is(jso) || AreaElement.is(jso)) {
            return;
          }

          // handle event in active scheme
          int digest = CharCodeWithModifiers.computeKeyDigest(signalEvent);
          preventDefaultBrowserAction((KeyboardEvent) event, digest);

          List<String> actionIds = getActive().getActionIds(digest);

          if (!actionIds.isEmpty()) {
            runActions(actionIds, event);
          }
          // else handle event in global scheme
          else if (!(actionIds = getGlobal().getActionIds(digest)).isEmpty()) {
            runActions(actionIds, event);
          }

          // default, lets this event handle other part of the IDE
        }
      };
  if (UserAgent.isFirefox()) {
    // firefox fires keypress events
    documentElement.addEventListener(Event.KEYPRESS, downListener, true);
  } else {
    // webkit fires keydown events
    documentElement.addEventListener(Event.KEYDOWN, downListener, true);
  }
}
 
Example 46
Project: che   File: CheckBoxRender.java   Source Code and License 5 votes vote down vote up
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");
  }
}
 
Example 47
Project: r01fb   File: ViewEnableDisableDelegate.java   Source Code and License 5 votes vote down vote up
@Override
public void enable() {
	_disabled = false;
	_uiObj.getElement().removeClassName("disabled");
	_uiObj.getElement().addClassName("enabled");		// enable the element
	
	// Enable all input elements
	Collection<InputElement> childInputEls = GWTElemental.getChildElementsOfTypeWithClass(_uiObj.getElement(),
																				 		  InputElement.class,TreeViewUtils.CHECKER_CLASS_NAME);
	GWTElemental.enableInputs(childInputEls);
}
 
Example 48
Project: r01fb   File: ViewEnableDisableDelegate.java   Source Code and License 5 votes vote down vote up
@Override
public void disable() {
	_disabled = true;
	_uiObj.getElement().removeClassName("enabled");
	_uiObj.getElement().addClassName("disabled");	// disable the element
	
	// Disable all input elements
	Collection<InputElement> childInputEls = GWTElemental.getChildElementsOfTypeWithClass(_uiObj.getElement(),
																				 		  InputElement.class,TreeViewUtils.CHECKER_CLASS_NAME);
	GWTElemental.disableInputs(childInputEls);
}
 
Example 49
Project: r01fb   File: TreeViewItem.java   Source Code and License 5 votes vote down vote up
private static LIElement _createBaseElement() {
	//		<li>
	//			[1] --- EXPANDER --
	//			<input type="checkbox" class="expander" disabled>	<!-- input.expander DISABLED = no child -->
       //        	<span class="expander"></span>
	//			
	//			[2] --- CHECK
       //        	<input type="checkbox" class="selection">
	//			
	//			[3] --- WIDGET
       //        	<!-- the widget --> <!-- if it's a text item: <label>Child Node 1</label> -->				
       //		</li>
	
	// [1] - Create the expander hidden checkbox and span to fake the expander image over the checkbox
	TreeViewExpanderDOMElements expanderDOMEls = TreeViewUtils.createExpanderDOMElements();
	
	// [2] - Create the selection checkbox
	InputElement checkINPUT = DOM.createInputCheck().cast();
	checkINPUT.addClassName(TreeViewUtils.CHECKER_CLASS_NAME);
	
	// [3] - Create the container LI
	LIElement containerLI = DOM.createElement("li").cast();
	Roles.getTreeitemRole().set(containerLI);
	
	// assemble the structure
	containerLI.appendChild(expanderDOMEls.getInputElement());
	containerLI.appendChild(expanderDOMEls.getSpanElement());
	containerLI.appendChild(checkINPUT);
	
	return containerLI;
}
 
Example 50
Project: r01fb   File: GWTElemental.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 51
Project: r01fb   File: GWTElemental.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 52
Project: gerrit   File: FileTable.java   Source Code and License 5 votes vote down vote up
MyTable(NativeMap<FileInfo> map, JsArray<FileInfo> list) {
  this.map = map;
  this.list = list;
  table.setWidth("");

  keysNavigation.add(
      new PrevKeyCommand(0, 'k', Util.C.patchTablePrev()),
      new NextKeyCommand(0, 'j', Util.C.patchTableNext()));
  keysNavigation.add(new OpenKeyCommand(0, 'o', Util.C.patchTableOpenDiff()));
  keysNavigation.add(new OpenKeyCommand(0, KeyCodes.KEY_ENTER, Util.C.patchTableOpenDiff()));

  keysNavigation.add(
      new OpenFileCommand(list.length() - 1, 0, '[', Resources.C.openLastFile()),
      new OpenFileCommand(0, 0, ']', Resources.C.openCommitMessage()));

  keysAction.add(
      new KeyCommand(0, 'r', PatchUtil.C.toggleReviewed()) {
        @Override
        public void onKeyPress(KeyPressEvent event) {
          int row = getCurrentRow();
          if (1 <= row && row <= MyTable.this.list.length()) {
            FileInfo info = MyTable.this.list.get(row - 1);
            InputElement b = getReviewed(info);
            boolean c = !b.isChecked();
            setReviewed(info, c);
            b.setChecked(c);
          }
        }
      });

  setSavePointerId((!base.isBase() ? base.asString() + ".." : "") + curr.toString());
}
 
Example 53
Project: gerrit   File: FileTable.java   Source Code and License 5 votes vote down vote up
private InputElement getReviewed(FileInfo info) {
  CellFormatter fmt = table.getCellFormatter();
  Element e = fmt.getElement(1 + info._row(), 1);
  return InputElement.as(e.getFirstChildElement());
}
 
Example 54
Project: platypus-js   File: NullableTextBox.java   Source Code and License 5 votes vote down vote up
public NullableTextBox(Element elem) {
	super(elem);
	inputElem = InputElement.as(elem);
}
 
Example 55
Project: platypus-js   File: MenuItemCheckBox.java   Source Code and License 5 votes vote down vote up
@Override
protected void regenerate() {
    getElement().setInnerSafeHtml(generateHtml());
    leftMark = getElement().getFirstChildElement().getFirstChildElement();
    inputElem = (InputElement) leftMark.getFirstChildElement();
    field = (Element) getElement().getFirstChildElement().getLastChild();
}
 
Example 56
Project: qafe-platform   File: FileUploadRenderer.java   Source Code and License 5 votes vote down vote up
private void init(FileUpload fileUpload, Button uploadButton) {
	if (fileUpload != null) {
		((InputElement)fileUpload.getElement().cast()).setValue("");	
	}
	if (uploadButton != null) {
		uploadButton.setEnabled(false);	
	}
}
 
Example 57
Project: gwt-gantt   File: CellTextImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Update the view data based on the current value.
 *
 * @param parent the parent element
 * @param viewData the {@link ViewData} object to update
 * @param isEditing true if in edit mode
 * @return the new value
 */
private String updateViewData(Element parent, ViewData viewData,
    boolean isEditing) {
  InputElement input = (InputElement) parent.getFirstChild();
  String value = input.getValue();
  viewData.setText(value);
  viewData.setEditing(isEditing);
  return value;
}
 
Example 58
Project: sigmah   File: ButtonFileUploadField.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setName(String name) {
	this.name = name;
	if (rendered) {
		file.dom.removeAttribute("name");
		if (name != null) {
			((InputElement) file.dom.cast()).setName(name);
		}
	}
}
 
Example 59
Project: avro-ui   File: FilterTextInputCell.java   Source Code and License 5 votes vote down vote up
@Override
public void onBrowserEvent(Context context, Element parent, String value,
    NativeEvent event, ValueUpdater<String> valueUpdater) {
    
  super.onBrowserEvent(context, parent, value, event, valueUpdater);

  // Ignore events that don't target the input.
  InputElement input = getInputElement(parent);
  Element target = event.getEventTarget().cast();
  if (!input.isOrHasChild(target)) {
    return;
  }

  String eventType = event.getType();
  Object key = context.getKey();
  if (BrowserEvents.BLUR.equals(eventType)) {
    finishEditing(parent, value, key, valueUpdater);
  } else if (BrowserEvents.CHANGE.equals(eventType) || 
          BrowserEvents.KEYUP.equals(eventType) ||
          PASTE.equals(eventType)) {
    ViewData vd = getViewData(key);
    if (vd == null) {
      vd = new ViewData(value);
      setViewData(key, vd);
    }
    
    String newValue = input.getValue();
    
    vd.setCurrentValue(input.getValue());
    
    if (valueUpdater != null && !vd.getCurrentValue().equals(vd.getLastValue())) {
        vd.setLastValue(newValue);
        valueUpdater.update(newValue);
    }
  }
}
 
Example 60
Project: gwtbootstrap3   File: CheckBoxButton.java   Source Code and License 5 votes vote down vote up
protected CheckBoxButton(InputElement element) {
    super(DOM.createLabel(), element);

    setStyleName(Styles.BTN);
    setType(ButtonType.DEFAULT);

    getElement().appendChild(inputElem);
    getElement().appendChild(Document.get().createTextNode(" "));
    getElement().appendChild(labelElem);
    getElement().appendChild(Document.get().createTextNode(" "));
}