/** * Sets the style classes for the current field. * * @param newValue * The new style classes. * * @return Returns the current field to allow for chaining. */ public E styleClass(String... newValue) { styleClass.setAll(newValue); return (E) this; }
@Override public boolean setAll(E[] elements) { return delegate.setAll(elements); }
@Override public boolean setAll(Collection<? extends E> elements) { return delegate.setAll(elements); }
/** * Updates the list of available items to a new list, along with a * pre-defined selection. * * @param newValue * The new list of items. * @param newSelection * The new pre-defined selection. * * @return Returns the current field to allow for chaining. */ public MultiSelectionField<V> items(List<V> newValue, List<Integer> newSelection) { items.setAll(newValue); newSelection.forEach(i -> selection.add(items.get(i))); persistentSelection.setAll(selection.getValue()); return this; }
/** * Stores the field's current selection in its persistent selection. This * stores the user's changes in the model. */ public void persist() { if (!isValid()) { return; } persistentSelection.setAll(selection.getValue()); fireEvent(FieldEvent.fieldPersistedEvent(this)); }
/** * Sets the field's current selection to its persistent selection, thus * resetting any changes made by the user. */ public void reset() { if (!hasChanged()) { return; } selection.setAll(persistentSelection.getValue()); fireEvent(FieldEvent.fieldResetEvent(this)); }
if (!validateRequired()) { if (isI18N() && requiredErrorKey.get() != null) { this.errorMessageKeys.setAll(requiredErrorKey.get()); } else if (requiredError.get() != null) { this.errorMessages.setAll(requiredError.get()); errorMessageKeys.setAll(errorMessages); } else { this.errorMessages.setAll(errorMessages);
errorMessageKeys.setAll(requiredErrorKey.get()); } else if (!requiredError.get().isEmpty()) { errorMessages.setAll(requiredError.get()); } catch (Exception e) { if (isI18N() && !formatErrorKey.get().isEmpty()) { errorMessageKeys.setAll(formatErrorKey.get()); } else if (!formatError.get().isEmpty()) { errorMessages.setAll(formatError.get()); errorMessageKeys.setAll(errorMessages); } else { this.errorMessages.setAll(errorMessages);
/** * Updates the list of available items to a new list, along with a * pre-defined selection. * * @param newValue * The new list of items. * @param newSelection * The new pre-defined selection. * * @return Returns the current field to allow for chaining. */ public SingleSelectionField<V> items(List<V> newValue, int newSelection) { items.setAll(newValue); if (newSelection != -1) { this.selection.setValue(items.get(newSelection)); this.persistentSelection.setValue(this.selection.getValue()); } return this; }
/** * Internal constructor for the {@code Field} class. To create new elements, * see the static factory methods in this class. * * @see Field::ofStringType * @see Field::ofIntegerType * @see Field::ofDoubleType * @see Field::ofBooleanType * @see Field::ofMultiSelectionType * @see Field::ofSingleSelectionType */ protected Field() { // Whenever one of the translatable elements' keys change, update the // displayed value based on the new translation. labelKey.addListener((observable, oldValue, newValue) -> label.setValue(translationService.translate(newValue))); tooltipKey.addListener((observable, oldValue, newValue) -> tooltip.setValue(translationService.translate(newValue))); placeholderKey.addListener((observable, oldValue, newValue) -> placeholder.setValue(translationService.translate(newValue))); labelDescriptionKey.addListener((observable, oldValue, newValue) -> labelDescription = asLabel(translationService.translate(newValue), LABEL_DESCRIPTION_STYLE_CLASS)); valueDescriptionKey.addListener((observable, oldValue, newValue) -> valueDescription = asLabel(translationService.translate(newValue), VALUE_DESCRIPTION_STYLE_CLASS)); requiredErrorKey.addListener((observable, oldValue, newValue) -> validate()); // Whenever the errorMessageKeys change, update the displayed // label to the new translation. This maps the keys to their translated // representation. errorMessageKeys.addListener((observable, oldValue, newValue) -> errorMessages.setAll(errorMessageKeys.stream() .map(s -> translationService.translate(s)) .collect(Collectors.toList()))); }