@Override public void onLazyLoadingSuccessful(final Collection<ViewObject> children) { // GWT.log("====>" + this.getText() + " > " + (children != null ? children.size() : 0) + " child loaded"); // Remove the loading... label LabelElement loadingLabel = _childLoadingSPANElement(); LIElement parentLI = this.getElement().cast(); parentLI.removeChild(loadingLabel); // if the number of children loaded is 0 (there where no child items), hide the expander // otherwise paint the children if (CollectionUtils.isNullOrEmpty(children)) { _expanderINPUTElement().setDisabled(true); } else { this.paintChildren(children); } }
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); }
RadioContainer(T value) { this.value = value; Container newContainer = null; Container label = new Container(LabelElement.TAG); if (Type.INLINE.equals(InputRadio.this.type)) { newContainer = label; } else { newContainer = new Container(); newContainer.append(label); } this.initWidget(newContainer); label.getElement().appendChild(this.radioElement); label.getElement().appendChild( Document.get().createTextNode(" " + InputRadio.this.getChoiceRenderer().renderItem(value))); StyleUtils.addStyle(newContainer, InputRadio.this.type); newContainer.addDomHandler(this, ClickEvent.getType()); InputRadio.this.itemsContainer.put(value, this); }
CheckboxContainer(T value) { this.value = value; Container newContainer = null; Container label = new Container(LabelElement.TAG); if (Type.INLINE.equals(InputCheckBox.this.type)) { newContainer = label; } else { newContainer = new Container(); InputCheckBox.this.container.append(label); } this.initWidget(newContainer); label.getElement().appendChild(this.checkboxElement); label.getElement().appendChild( Document.get().createTextNode(" " + InputCheckBox.this.getChoiceRenderer().renderItem(value))); StyleUtils.addStyle(newContainer, InputCheckBox.this.type); newContainer.addDomHandler(this, ClickEvent.getType()); InputCheckBox.this.itemsContainer.put(value, this); }
/** * Sets the text associated with the item at a given index. * * @param index the index of the item to be set * @param text the item's new text * @throws IndexOutOfBoundsException if the index is out of range */ public void setItemText(int index, String text) { checkIndex(index); final Element optionElement = (Element) optionsPanel.getElement().getChild(index); final LabelElement labelElement = (LabelElement) optionElement.getElementsByTagName("label").getItem(0); labelElement.setInnerText(text); if (selectedIndex == index) { currentInputElement.setValue(text); } }
/** * 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 LabelElement labelElement = (LabelElement) optionElement.getElementsByTagName("label").getItem(0); return labelElement.getInnerText(); }
/** * Sets the text associated with the item at a given index. * * @param index the index of the item to be set * @param text the item's new text * @throws IndexOutOfBoundsException if the index is out of range */ public void setItemText(int index, String text) { checkIndex(index); final Element optionElement = (Element) optionsPanel.getElement().getChild(index); final LabelElement labelElement = (LabelElement) optionElement.getElementsByTagName("label").getItem(0); labelElement.setInnerText(text); if (selectedIndex == index) { currentItemLabel.setInnerText(text); } }
@Override public void onLazyLoadingInProgress() { // [1] - Create a child label element with the "loading..." text LabelElement loadingLabelEl = DOM.clone(BASE_LOADING_ELEM, // a label true) // deep cloning .cast(); // [2] - set the label as a child of the item (the LI) LIElement parentLI = this.getElement().cast(); parentLI.insertAfter(loadingLabelEl, _widget.getElement()); // the loading label is ALLWAYS after the widget }
private Label(Label source) { super(source); this.labelElement = LabelElement.as(this.getElement()); StyleUtils.addStyle(this, Label.STYLE_CONTROL_LABEL); this.path = source.path; this.setText(source.text); if (source.htmlFor != null) { this.setHtmlFor(source.htmlFor); } }
/** * 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. * * 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 Radio(String name) { super(DOM.createDiv(), Document.get().createRadioInputElement(name)); setStyleName(Styles.RADIO); LabelElement label = Document.get().createLabelElement(); label.appendChild(inputElem); label.appendChild(labelElem); getElement().appendChild(label); }
public CheckBox() { this(DOM.createDiv(), Document.get().createCheckInputElement()); setStyleName(Styles.CHECKBOX); LabelElement label = Document.get().createLabelElement(); label.appendChild(inputElem); label.appendChild(labelElem); getElement().appendChild(label); }
private LabelElement createLabel(Document document, String className) { LabelElement result = document.createLabelElement(); result.addClassName(className); return result; }
private LabelElement createChildLabel(Document document, Element parent, String nameId) { LabelElement result = createLabel(document, nameId); parent.appendChild(result); return result; }
/** * @return impl nodelet as {@link LabelElement} */ private LabelElement getImpl(ContentElement element) { return LabelElement.as(element.getImplNodelet()); }
public void setHtmlFor(String htmlFor) { ((LabelElement) getElement().cast()).setHtmlFor(htmlFor); }
private static LabelElement _createBaseLoadingElement() { LabelElement label = DOM.createLabel().cast(); label.addClassName("loading"); label.setInnerHTML("loading..."); return label; }
LabelElement _childLoadingSPANElement() { LIElement containerLI = this.getElement().cast(); if (containerLI.getChildCount() < 4) return null; LabelElement loadingSPAN = containerLI.getChild(4).cast(); return loadingSPAN; }
@Override public void onLazyLoadingError(final String err) { // Change the loading... label for ERROR!! LabelElement loadingLabel = _childLoadingSPANElement(); loadingLabel.setInnerHTML("ERROR!!!"); }
public Label() { super(LabelElement.TAG); this.labelElement = LabelElement.as(this.getElement()); StyleUtils.addStyle(this, Label.STYLE_CONTROL_LABEL); }
private void setLabelFor(InputElement radio, LabelElement label) { if (radio.getId().length()==0) radio.setId(DOM.createUniqueId()); label.setHtmlFor(radio.getId()); }