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

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

Introduction

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

Prototype

public static Element createLabel() 

Source Link

Document

Creates an HTML LABEL element.

Usage

From source file:cc.alcina.framework.gwt.client.widget.FormLabel.java

License:Apache License

/**
 * Creates an empty span panel.
 */
public FormLabel(String html) {
    setElement(DOM.createLabel());
    getElement().setInnerHTML(html);
}

From source file:com.dianaui.universal.core.client.ui.CheckBoxButton.java

License:Apache License

protected CheckBoxButton(final InputElement element) {
    super(DOM.createLabel(), element);

    setStyleName(Styles.BTN);//w  ww .j  ava  2s.c  om
    setType(ButtonType.DEFAULT);

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

From source file:com.dianaui.universal.core.client.ui.InlineCheckBox.java

License:Apache License

public InlineCheckBox() {
    super(DOM.createLabel(), Document.get().createCheckInputElement());
    setStyleName(Styles.CHECKBOX_INLINE);

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

From source file:com.dianaui.universal.core.client.ui.InlineRadio.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.//  ww w  .  j a  v  a  2 s. c o m
 * <p/>
 * 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 InlineRadio(final String name) {
    super(DOM.createLabel(), Document.get().createRadioInputElement(name));
    setStyleName(Styles.RADIO_INLINE);

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

From source file:com.dianaui.universal.core.client.ui.RadioButton.java

License:Apache License

protected RadioButton(final InputElement element) {
    super(DOM.createLabel(), element);

    setStyleName(Styles.BTN);/*from  ww  w .j a va 2  s . com*/
    setType(ButtonType.DEFAULT);

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

    sinkEvents(Event.ONCLICK);
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.PermissionScreen.java

License:Apache License

private void fillServicePermissions(JSONObject servicePermissions) {
    for (final String key : servicePermissions.keySet()) {
        String parentName = key.substring(0, 1).toUpperCase() + key.substring(1);
        Element e = DOM.getElementById("permission" + parentName);
        JSONArray permissions = JSONUtils.sort(servicePermissions.get(key).isArray());
        for (int i = 0; i < permissions.size(); i++) {
            final String permission = permissions.get(i).isString().stringValue();
            Element d = DOM.createDiv();
            Element l = DOM.createLabel();
            l.setInnerText(permission.replaceAll("_", " "));
            final Element c = DOM.createInputCheck();
            PageAssembler.attachHandler(c, Event.ONCHANGE, new EventCallback() {
                @Override// w w  w.  j a  v  a  2s  .c o m
                public void onEvent(Event event) {
                    String destinationType = DOM.getElementById(DESTINATION_ENTITY_TYPE)
                            .getPropertyString("value");
                    if (!c.getPropertyBoolean("checked")) {
                        RusselApi.removePermission(permission, !type.equals(TYPE_RESOURCE) ? source
                                : destinationType.equalsIgnoreCase("service") ? key
                                        : DOM.getElementById(DESTINATION_ENTITY).getPropertyString("value"),
                                !type.equals(TYPE_RESOURCE) ? type : destinationType,
                                !type.equals(TYPE_RESOURCE) ? destinationType.equalsIgnoreCase("service") ? key
                                        : DOM.getElementById(DESTINATION_ENTITY).getPropertyString("value")
                                        : source,
                                !type.equals(TYPE_RESOURCE) ? destinationType : type,
                                new ESBCallback<ESBPacket>() {
                                    @Override
                                    public void onSuccess(ESBPacket esbPacket) {
                                        c.setPropertyBoolean("checked", false);
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        c.setPropertyBoolean("checked", true);
                                    }
                                });
                    } else {
                        RusselApi.addPermission(permission, !type.equals(TYPE_RESOURCE) ? source
                                : destinationType.equalsIgnoreCase("service") ? key
                                        : DOM.getElementById(DESTINATION_ENTITY).getPropertyString("value"),
                                !type.equals(TYPE_RESOURCE) ? type : destinationType,
                                !type.equals(TYPE_RESOURCE) ? destinationType.equalsIgnoreCase("service") ? key
                                        : DOM.getElementById(DESTINATION_ENTITY).getPropertyString("value")
                                        : source,
                                !type.equals(TYPE_RESOURCE) ? destinationType : type,
                                new ESBCallback<ESBPacket>() {
                                    @Override
                                    public void onSuccess(ESBPacket esbPacket) {
                                        c.setPropertyBoolean("checked", true);
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        c.setPropertyBoolean("checked", false);
                                    }
                                });
                    }
                }
            });
            c.setId(permission + parentName);
            d.appendChild(c);
            d.appendChild(l);
            d.appendChild(createBreak());
            e.appendChild(d);
        }
    }
}

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 {//ww  w  .j a va2  s .  c  om
        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.github.gwtbootstrap.client.ui.CheckBox.java

License:Apache License

protected CheckBox(Element elem) {
    super(DOM.createLabel());

    assert elem.hasAttribute("type") : "The elem should has type attributes";

    //TODO 2012/05/06 ohashi keisuke. ugly code......
    if (Constants.CHECKBOX.toLowerCase().equals(elem.getAttribute("type").toLowerCase())) {
        this.setStyleName(Constants.CHECKBOX);
    } else if (Constants.RADIO.toLowerCase().equals(elem.getAttribute("type").toLowerCase())) {
        this.setStyleName(Constants.RADIO);
    }/*from w  w  w  .j av a2  s. com*/

    inputElem = InputElement.as(elem);
    spanElem = Document.get().createSpanElement();

    getElement().appendChild(inputElem);
    getElement().appendChild(spanElem);

    String uid = DOM.createUniqueId();
    inputElem.setPropertyString("id", uid);
    asLabel().setHtmlFor(uid);
    directionalTextHelper = new DirectionalTextHelper(spanElem, false);
    setTabIndex(0);
}

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

License:Apache License

/**
 * Construct a radio button//from   w w  w  .  j  av  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.ponysdk.core.terminal.ui.PTFileUpload.java

License:Apache License

@Override
public boolean update(final ReaderBuffer buffer, final BinaryModel binaryModel) {
    final ServerToClientModel model = binaryModel.getModel();
    if (ServerToClientModel.NAME == model) {
        fileUpload.setName(binaryModel.getStringValue());
        return true;
    } else if (ServerToClientModel.ENABLED == model) {
        fileUpload.setEnabled(binaryModel.getBooleanValue());
        return true;
    } else if (ServerToClientModel.TEXT == model) {
        if (label == null) {
            label = DOM.createLabel().cast();
            label.setHtmlFor(fileUploadId);
            container.getElement().insertFirst(label);
        }//from   www . j av  a 2 s . c om
        label.setInnerText(binaryModel.getStringValue());
        return true;
    } else if (ServerToClientModel.CLEAR == model) {
        uiObject.reset();
        return true;
    } else {
        return super.update(buffer, binaryModel);
    }
}