@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); focusHandlerRegistration = EventHelper.updateFocusHandler(this, focusHandlerRegistration); blurHandlerRegistration = EventHelper.updateBlurHandler(this, blurHandlerRegistration); if (null != getState().errorMessage) { if (getWidget().errorIndicatorElement == null) { getWidget().errorIndicatorElement = DOM.createSpan(); getWidget().errorIndicatorElement.setInnerHTML(" "); DOM.setElementProperty(getWidget().errorIndicatorElement, "className", "v-errorindicator"); DOM.appendChild(getWidget().getElement(), getWidget().errorIndicatorElement); DOM.sinkEvents(getWidget().errorIndicatorElement, VTooltip.TOOLTIP_EVENTS | Event.ONCLICK); } else { DOM.setStyleAttribute(getWidget().errorIndicatorElement, "display", ""); } } else if (getWidget().errorIndicatorElement != null) { DOM.setStyleAttribute(getWidget().errorIndicatorElement, "display", "none"); } if (isReadOnly()) { getWidget().setEnabled(false); } if (getIcon() != null) { if (getWidget().icon == null) { getWidget().icon = new Icon(getConnection()); DOM.insertChild(getWidget().getElement(), getWidget().icon.getElement(), 1); getWidget().icon.sinkEvents(VTooltip.TOOLTIP_EVENTS); getWidget().icon.sinkEvents(Event.ONCLICK); } getWidget().icon.setUri(getIcon()); } else if (getWidget().icon != null) { // detach icon DOM.removeChild(getWidget().getElement(), getWidget().icon.getElement()); getWidget().icon = null; } // Set text getWidget().setText(getState().caption); getWidget().setValue(getState().checked); getWidget().immediate = getState().immediate; }
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); getWidget().disableOnClick = getState().disableOnClick; focusHandlerRegistration = EventHelper.updateFocusHandler(this, focusHandlerRegistration); blurHandlerRegistration = EventHelper.updateBlurHandler(this, blurHandlerRegistration); // Set text VCaption.setCaptionText(getWidget(), getState()); // handle error if (null != getState().errorMessage) { if (getWidget().errorIndicatorElement == null) { getWidget().errorIndicatorElement = DOM.createSpan(); getWidget().errorIndicatorElement.setClassName("v-errorindicator"); } getWidget() .getElement() .insertBefore(getWidget().errorIndicatorElement, getWidget().captionElement); } else if (getWidget().errorIndicatorElement != null) { getWidget().getElement().removeChild(getWidget().errorIndicatorElement); getWidget().errorIndicatorElement = null; } if (getWidget().icon != null) { getWidget().getElement().removeChild(getWidget().icon.getElement()); getWidget().icon = null; } Icon icon = getIcon(); if (icon != null) { getWidget().icon = icon; getWidget().getElement().insertBefore(icon.getElement(), getWidget().captionElement); icon.setAlternateText(getState().iconAltText); } }