protected void ensureDomEventHandlers() { addChangeHandler(pevent -> ValueChangeEvent.fire(this, this.getValue())); }
@Override public HandlerRegistration addValueChangeHandler(final ValueChangeHandler<T> phandler) { // Is this the first value change handler? If so, time to add handlers if (!this.valueChangeHandlerInitialized) { this.ensureDomEventHandlers(); this.valueChangeHandlerInitialized = true; } return this.addHandler(phandler, ValueChangeEvent.getType()); }
/** * fill entries of the listbox. * * @param pentries list of entries */ public final void fillEntryCollections(final Collection<? extends IdAndNameBean<T>> pentries) { this.entries.clear(); this.entries.addAll(pentries); clear(); for (final IdAndNameBean<T> entry : this.entries) { this.addItem(entry.getName(), Objects.toString(entry.getId())); } }
@Override public void showErrors(final List<EditorError> perrors) { final SelectElement selectElement = getElement().cast(); final Set<String> messages = perrors.stream().filter(error -> this.editorErrorMatches(error)) .map(error -> error.getMessage()).collect(Collectors.toSet()); if (messages.isEmpty()) { if (FeatureCheck.supportCustomValidity(selectElement)) { selectElement.setCustomValidity(StringUtils.EMPTY); } if (this.validationMessageElement == null) { selectElement.setTitle(StringUtils.EMPTY); } else { this.validationMessageElement.getElement().removeAllChildren(); } } else { final String messagesAsString = ErrorMessageFormater.messagesToString(messages); if (FeatureCheck.supportCustomValidity(selectElement)) { selectElement.setCustomValidity(messagesAsString); } if (this.validationMessageElement == null) { selectElement.setTitle(messagesAsString); } else { this.validationMessageElement.getElement() .setInnerSafeHtml(ErrorMessageFormater.messagesToList(messages)); } } }
@Override public void setAutofocus(final boolean arg) { final SelectElement selectElement = getElement().cast(); selectElement.setAutofocus(arg); }
/** * constructor. * * @param pentries collection of id and name bean entries */ public IdAndNameListBox(final Collection<? extends IdAndNameBean<T>> pentries) { super(); this.entries = new ArrayList<>(); this.editor = new ExtendedValueBoxEditor<>(this, null); this.fillEntryCollections(pentries); }
/** * Checks if a error belongs to this widget. * * @param perror editor error to check * @return true if the error belongs to this widget */ protected boolean editorErrorMatches(final EditorError perror) { return perror != null && perror.getEditor() != null && (equals(perror.getEditor()) || perror.getEditor().equals(this.asEditor())); }
@Override public T getValue() { if (getSelectedIndex() >= 0 && getSelectedIndex() < this.entries.size()) { return this.entries.get(getSelectedIndex()).getId(); } return null; }
@Override public void showErrors(final List<EditorError> perrors) { final SelectElement selectElement = getElement().cast(); final Set<String> messages = perrors.stream().filter(error -> this.editorErrorMatches(error)) .map(error -> error.getMessage()).collect(Collectors.toSet()); if (messages.isEmpty()) { if (FeatureCheck.supportCustomValidity(selectElement)) { selectElement.setCustomValidity(StringUtils.EMPTY); } if (this.validationMessageElement == null) { selectElement.setTitle(StringUtils.EMPTY); } else { this.validationMessageElement.getElement().removeAllChildren(); } } else { final String messagesAsString = ErrorMessageFormater.messagesToString(messages); if (FeatureCheck.supportCustomValidity(selectElement)) { selectElement.setCustomValidity(messagesAsString); } if (this.validationMessageElement == null) { selectElement.setTitle(messagesAsString); } else { this.validationMessageElement.getElement() .setInnerSafeHtml(ErrorMessageFormater.messagesToList(messages)); } } }
@Override public boolean isAutofocus() { final SelectElement selectElement = getElement().cast(); return selectElement.isAutofocus(); }
/** * constructor. * * @param pentries collection of id and name bean entries */ public IdAndNameListBox(final Collection<? extends IdAndNameBean<T>> pentries) { super(); this.entries = new ArrayList<>(); this.editor = new ExtendedValueBoxEditor<>(this, null); this.fillEntryCollections(pentries); }
/** * Checks if a error belongs to this widget. * * @param perror editor error to check * @return true if the error belongs to this widget */ protected boolean editorErrorMatches(final EditorError perror) { return perror != null && perror.getEditor() != null && (equals(perror.getEditor()) || perror.getEditor().equals(this.asEditor())); }
@Override public T getValue() { if (getSelectedIndex() >= 0 && getSelectedIndex() < this.entries.size()) { return this.entries.get(getSelectedIndex()).getId(); } return null; }
@Override public HandlerRegistration addValueChangeHandler(final ValueChangeHandler<T> phandler) { // Is this the first value change handler? If so, time to add handlers if (!this.valueChangeHandlerInitialized) { this.ensureDomEventHandlers(); this.valueChangeHandlerInitialized = true; } return this.addHandler(phandler, ValueChangeEvent.getType()); }
/** * fill entries of the listbox. * * @param pentries list of entries */ public final void fillEntryCollections(final Collection<? extends IdAndNameBean<T>> pentries) { this.entries.clear(); this.entries.addAll(pentries); clear(); for (final IdAndNameBean<T> entry : this.entries) { this.addItem(entry.getName(), Objects.toString(entry.getId())); } }
protected void ensureDomEventHandlers() { addChangeHandler(pevent -> ValueChangeEvent.fire(this, this.getValue())); }
@Override public void setAutofocus(final boolean arg) { final SelectElement selectElement = getElement().cast(); selectElement.setAutofocus(arg); }
@Override public boolean isAutofocus() { final SelectElement selectElement = getElement().cast(); return selectElement.isAutofocus(); }