List of usage examples for com.google.gwt.dom.client LabelElement setInnerText
@Override
public void setInnerText(String text)
From source file:com.isotrol.impe3.pms.gui.client.widget.LoginPanel.java
License:Open Source License
/** * Inits this container inner components.<br/> *//*from w ww .j av a 2s . c o m*/ private void initComponent() { LayoutContainer lc = new LayoutContainer(formSupport.getStandardLayout(false)); lc.addStyleName(pmsStyles.loginPanel()); lc.setAutoWidth(true); tfErrorMessage = new LabelField(); tfErrorMessage.addStyleName(styles.labelInfoMessage()); tfErrorMessage.addStyleName(styles.redMessage()); tfErrorMessage.setVisible(false); lc.add(tfErrorMessage); add(lc); lcAuthenticating = new LayoutContainer(new ColumnLayout()); lcAuthenticating.setVisible(false); lcAuthenticating.setStyleName(styles.marginBottom10px()); // add "loading" icon: lcAuthenticating.add(new Html("<div class='loading-icon' style='float: right; margin-right: 5px;'></div>"), new ColumnData(165)); // add "authenticating" label: Label tfAuthenticating = new Label(pmsMessages.msgAuthenticating()); tfAuthenticating.addStyleName(styles.labelInfoMessage()); lcAuthenticating.add(tfAuthenticating); add(lcAuthenticating); KeyPressHandler keyEnterPressHandler = new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getUnicodeCharCode() == KeyCodes.KEY_ENTER) { pmsLoginForm.submit(); } } }; tfUsername = (InputElement) Document.get().getElementById(USER_FIELD_ID); // wrap the input element in a gwt textbox to listen 'enter' key press TextBox tbUserName = TextBox.wrap(tfUsername); if (tbUserName != null) { tbUserName.addKeyPressHandler(keyEnterPressHandler); } tfPassword = (InputElement) Document.get().getElementById(PASSWORD_FIELD_ID); PasswordTextBox tbPassword = PasswordTextBox.wrap(tfPassword); if (tbPassword != null) { tbPassword.addKeyPressHandler(keyEnterPressHandler); } LabelElement userLabel = (LabelElement) Document.get().getElementById(USER_LABEL_ID); userLabel.setInnerText(pmsMessages.labelUsername()); LabelElement pwdLabel = (LabelElement) Document.get().getElementById(PASSWORD_LABEL_ID); pwdLabel.setInnerText(pmsMessages.labelPassword()); // Get a handle to the form and set its action. The Wraping for form must be after the input wrapings pmsLoginForm = FormPanel.wrap(Document.get().getElementById(FORM_ID), false); // form.setAction("javascript:__gwt_login()"); // form.setAction("javascript:''"); pmsLoginForm.addSubmitHandler(new SubmitHandler() { /** * Add login form validations (user and password are required fields) * @see com.google.gwt.user.client.ui.FormPanel.SubmitHandler#onSubmit(com.google.gwt.user.client.ui.FormPanel.SubmitEvent) */ public void onSubmit(SubmitEvent event) { if (tfUsername.getValue() == null || tfUsername.getValue().equals("")) { tfErrorMessage.setValue(pmsMessages.msgErrorUserRequired()); tfErrorMessage.show(); event.cancel(); } else if (tfPassword.getValue() == null || tfPassword.getValue().equals("")) { tfErrorMessage.setValue(pmsMessages.msgErrorPasswordRequired()); tfErrorMessage.show(); event.cancel(); } else { initAuthentication(); } } }); // Get the submit button for text localization final ButtonElement submit = (ButtonElement) Document.get().getElementById(SUBMIT_BUTTON_ID); submit.setInnerText(messages.labelAccept()); SelectionListener<ButtonEvent> listener = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { submit.click(); } }; Button bAccept = buttonsSupport.createAcceptButton(listener); addButton(bAccept); // Add the form to the panel lc.add(pmsLoginForm); }
From source file:org.eclipse.che.ide.ui.listbox.CustomComboBox.java
License:Open Source License
/** * Sets the text associated with the item at a given index. * * @param index/*from w ww. j av a 2s . c o m*/ * 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); } }
From source file:org.eclipse.che.ide.ui.listbox.CustomListBox.java
License:Open Source License
/** * Sets the text associated with the item at a given index. * * @param index/*from w w w .j a v a2 s. com*/ * 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); } }
From source file:ru.fly.client.ui.field.checkbox.CheckBoxField.java
License:Apache License
private void buildContent() { if (!isAttached()) return;// w w w . jav a 2 s . c o m setHeight(iconSize + 4); getElement().removeAll(); getElement().appendChild(getInputElement()); getInputElement().getStyle().setMarginTop((iconSize - 12) / 2 + 2, Style.Unit.PX); if (imgRes != null) { ImageElement img = DOM.createImg().cast(); img.setSrc(imgRes.getSafeUri().asString()); img.setWidth(iconSize); img.setHeight(iconSize); getElement().appendChild(img); } if (text != null) { LabelElement label = DOM.createLabel().cast(); label.setInnerText(text == null ? "" : text); label.getStyle().setLineHeight(iconSize + 4, Style.Unit.PX); getElement().appendChild(label); } DOM.setEventListener(getInputElement(), new EventListener() { @Override public void onBrowserEvent(Event event) { if (!isEnabled()) event.preventDefault(); else if (event.getTypeInt() == Event.ONCLICK) { setValue(getValue()); fireEvent(new ValueChangeEvent<Boolean>(getValue())); } } }); DOM.sinkEvents(getInputElement(), Event.ONCLICK | Event.ONMOUSEDOWN); }