Example usage for com.google.gwt.user.client DOM createInputRadio

List of usage examples for com.google.gwt.user.client DOM createInputRadio

Introduction

In this page you can find the example usage for com.google.gwt.user.client DOM createInputRadio.

Prototype

public static Element createInputRadio(String name) 

Source Link

Document

Creates an HTML INPUT type='RADIO' element.

Usage

From source file:com.extjs.gxt.ui.client.widget.form.CheckBox.java

License:sencha.com license

@Override
protected void onRender(Element target, int index) {
    if (this instanceof Radio) {
        input = new El(DOM.createInputRadio(name));
    } else {//from   w w  w  .  ja  va 2 s . c  o  m
        input = new El(DOM.createInputCheck());
    }

    input.setId(XDOM.getUniqueId());
    input.makePositionable();

    wrap = new El(DOM.createDiv());
    wrap.dom.setPropertyString("hideFocus", "hideFocus");
    wrap.dom.setClassName("x-form-check-wrap");
    wrap.dom.setAttribute("role", "presentation");
    wrap.dom.appendChild(input.dom);

    setElement(wrap.dom, target, index);
    wrap.makePositionable();
    if (boxLabel != null) {
        boxLabelEl = new El(DOM.createLabel());
        boxLabelEl.setElementAttribute("for", input.getId());
        boxLabelEl.setElementAttribute("htmlFor", input.getId());
        boxLabelEl.dom.setClassName("x-form-cb-label");
        boxLabelEl.makePositionable();
        wrap.dom.appendChild(boxLabelEl.dom);
        setBoxLabel(boxLabel);
    }

    super.onRender(target, index);

    setValueAttribute(valueAttribute);

    focusStyle = null;
}

From source file:com.extjs.gxt.ui.client.widget.form.Radio.java

License:sencha.com license

@Override
public void setName(String name) {
    this.name = name;
    if (afterRender) {
        replaceInputElement(DOM.createInputRadio(name));
        if (isAttached()) {
            alignElements();//from  ww w .j av  a  2 s  .c  o m
        }
    }
}

From source file:com.github.gwtbootstrap.client.ui.RadioButton.java

License:Apache License

/**
 * Creates a new radio associated with a particular group name. All radio
 * buttons associated with the same group name belong to a
 * mutually-exclusive set.//from  w  w w  .  j a  v a 2  s.  c o m
 * 
 * Radio buttons are grouped by their name attribute, so changing their name
 * using the setName() method will also change their associated group.
 * 
 * @param name
 *            the group name with which to associate the radio button
 */
@UiConstructor
public RadioButton(String name) {
    super(DOM.createInputRadio(name));

    sinkEvents(Event.ONCLICK);
    sinkEvents(Event.ONMOUSEUP);
    sinkEvents(Event.ONBLUR);
    sinkEvents(Event.ONKEYDOWN);
}

From source file:com.github.gwtbootstrap.client.ui.RadioButton.java

License:Apache License

/**
 * Change the group name of this radio button.
 * //from w  w w .j  ava2 s. c om
 * Radio buttons are grouped by their name attribute, so changing their name
 * using the setName() method will also change their associated group.
 * 
 * If changing this group name results in a new radio group with multiple
 * radio buttons selected, this radio button will remain selected and the
 * other radio buttons will be unselected.
 * 
 * @param name
 *            name the group with which to associate the radio button
 */
@Override
public void setName(String name) {
    // Just changing the radio button name tends to break groupiness,
    // so we have to replace it. Note that replaceInputElement is careful
    // not to propagate name when it propagates everything else
    replaceInputElement(DOM.createInputRadio(name));
}

From source file:com.googlecode.mgwt.ui.client.widget.input.radio.MRadioButton.java

License:Apache License

@Override
public void setName(String name) {
    replaceInputElement(DOM.createInputRadio(name));

}

From source file:com.googlecode.mgwt.ui.client.widget.MRadioButton.java

License:Apache License

/**
 * Construct a radio button//w w w .  j  a  v  a 2  s  .c  o  m
 * 
 * @param css the css to use
 * @param name the group name to use
 */
public MRadioButton(InputCss css, String name) {
    this.css = css;
    css.ensureInjected();
    setElement(DOM.createSpan());

    sinkEvents(Event.ONCHANGE);

    labelElement = LabelElement.as(DOM.createLabel());
    getElement().appendChild(labelElement);
    inputRadio = InputElement.as(DOM.createInputRadio(name));
    getElement().appendChild(inputRadio);

    addStyleName(css.radioButton());

    addTouchHandler(new TouchHandler() {

        private boolean ignore;
        private boolean labelOrContainer;
        private int start_x;
        private int start_y;

        private int last_x;
        private int last_y;

        @Override
        public void onTouchCanceled(TouchCancelEvent event) {
            if (ignore)
                return;

        }

        @Override
        public void onTouchEnd(TouchEndEvent event) {
            if (ignore)
                return;

            if (Math.abs(last_x - start_x) < Tap.RADIUS && Math.abs(last_y - start_y) < Tap.RADIUS) {
                if (labelOrContainer) {
                    inputRadio.setChecked(true);
                    ValueChangeEvent.fire(MRadioButton.this, true);
                }
            }

        }

        @Override
        public void onTouchMove(TouchMoveEvent event) {
            if (ignore)
                return;
            Touch touch = event.getTouches().get(0);
            last_x = touch.getPageX();
            last_y = touch.getPageY();

        }

        @Override
        public void onTouchStart(TouchStartEvent event) {

            ignore = inputRadio.isChecked();

            if (ignore)
                return;

            Touch touch = event.getTouches().get(0);
            start_x = touch.getPageX();
            start_y = touch.getPageY();
            last_x = start_x;
            last_y = start_y;

            EventTarget eventTarget = event.getNativeEvent().getEventTarget();
            labelOrContainer = true;
            if (com.google.gwt.dom.client.Element.is(eventTarget)) {
                com.google.gwt.dom.client.Element el = com.google.gwt.dom.client.Element.as(eventTarget);

                if (inputRadio.isOrHasChild(el)) {
                    labelOrContainer = false;
                }
            }

        }
    });

    addHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            ValueChangeEvent.fire(MRadioButton.this, true);

        }
    }, ChangeEvent.getType());
}

From source file:com.googlecode.mgwt.ui.client.widget.MRadioButton.java

License:Apache License

/** {@inheritDoc} */
@Override
public void setName(String name) {
    replaceInputElement(DOM.createInputRadio(name));

}

From source file:org.bonitasoft.web.toolkit.client.ui.component.form.entry.FieldsetRadio.java

License:Open Source License

@Override
protected Element createInput() {
    return DOM.createInputRadio(getJsId().toString());
}