/** * Gets the value of this progress bar. The value is a <code>float</code> * between 0 and 1 where 0 represents no progress at all and 1 represents * fully completed. * * @return the current progress value */ @Override public Float getValue() { return super.getValue(); }
/** * Sets the value of this progress bar. The value is a <code>float</code> * between 0 and 1 where 0 represents no progress at all and 1 represents * fully completed. * * @param newValue * the current progress value */ @Override public void setValue(Float newValue) { super.setValue(newValue); }
/** * @deprecated As of 7.0, replaced by * {@link #addValueChangeListener(Property.ValueChangeListener)} */ @Override @Deprecated public void addListener(Property.ValueChangeListener listener) { addValueChangeListener(listener); }
/** * Sets the value of the field using a value of the data source type. The * value given is converted to the field type and then assigned to the * field. This will update the property data source in the same way as when * {@link #setValue(Object)} is called. * * @param value * The value to set. Must be the same type as the data source. */ public void setConvertedValue(Object value) { setValue(convertFromModel(value)); }
/** * Returns true if the error indicator be hidden when painting the component * even when there are errors. * * This is a mostly internal method, but can be overridden in subclasses * e.g. if the error indicator should also be shown for empty fields in some * cases. * * @return true to hide the error indicator, false to use the normal logic * to show it when there are errors */ protected boolean shouldHideErrors() { // getErrorMessage() can still return something else than null based on // validation etc. return isRequired() && isEmpty() && getComponentError() == null; }
/** * Returns the field value. This is always identical to {@link #getValue()} * and only here because of clarity in the code that handles both the data * model value and the field value. * * @return The value of the field */ private T getFieldValue() { // Give the value from abstract buffers if the field if possible if (dataSource == null || isBuffered() || isModified()) { return getInternalValue(); } // There is no buffered value so use whatever the data model provides return convertFromModel(getDataSourceValue()); }
if (!SharedUtil.equals(newFieldValue, getInternalValue())) { if (!ignoreReadOnly && isReadOnly()) { throw new Property.ReadOnlyException(); T doubleConvertedFieldValue = convertFromModel( convertToModel(newFieldValue)); if (!SharedUtil.equals(newFieldValue, doubleConvertedFieldValue)) { if (repaintIsNotNeeded && (isRequired() || hasValidators() || getConverter() != null)) { repaintIsNotNeeded = false; if (!isInvalidAllowed()) { validate(newFieldValue); setInternalValue(newFieldValue); setModified(dataSource != null); if (!isBuffered() && dataSource != null && (isInvalidCommitted() || isValid())) { try { getPropertyDataSource() .setValue(convertToModel(newFieldValue)); setModified(false);
final Object oldValue = getInternalValue(); removePropertyListeners(); getState().propertyReadOnly = dataSource == null ? false : dataSource.isReadOnly(); && !ConverterUtil.canConverterPossiblyHandle(getConverter(), getType(), newDataSource.getType())) { setConverter(newDataSource.getType()); T fieldValue = convertFromModel(getDataSourceValue()); setInternalValue(fieldValue); setModified(false); if (getCurrentBufferedSourceException() != null) { setCurrentBufferedSourceException(null); setCurrentBufferedSourceException( new Buffered.SourceException(this, e)); setModified(true); throw getCurrentBufferedSourceException(); addPropertyListeners(); if (validators != null) { for (final Validator v : validators) { addValidator(v);
/** * This method hides validation errors on a required fields until the field * has been changed for the first time. Does pretty much the same as old * Vaadin Form did with its validationVisibleOnCommit, but eagerly per * field. * <p> * Fields that hide validation errors this way are available in * getFieldsWithIntiallyDisabledValidation() so they can be emphasized in * UI. */ public void hideInitialEmpyFieldValidationErrors() { fieldsWithInitiallyDisabledValidation.clear(); for (Field<?> f : getFields()) { if (f instanceof AbstractField) { final AbstractField<?> abstractField = (AbstractField<?>) f; if (abstractField.getErrorMessage() != null && abstractField. isRequired() && abstractField. isEmpty() && abstractField.isValidationVisible()) { final String propertyId = getPropertyId(abstractField). toString(); abstractField.setValidationVisible(false); fieldsWithInitiallyDisabledValidation.add(propertyId); } } } }
/** * Notifies the component that it is connected to an application. * * @see com.vaadin.ui.Component#attach() */ @Override public void attach() { super.attach(); localeMightHaveChanged(); if (!isListeningToPropertyEvents) { addPropertyListeners(); if (!isModified() && !isBuffered()) { // Update value from data source updateValueFromDataSource(); } } }
/** * Checks the validity of the Field. * * A field is invalid if it is set as required (using * {@link #setRequired(boolean)} and is empty, if one or several of the * validators added to the field indicate it is invalid or if the value * cannot be converted provided a converter has been set. * * The "required" validation is a built-in validation feature. If the field * is required and empty this method throws an EmptyValueException with the * error message set using {@link #setRequiredError(String)}. * * @see Validatable#validate() */ @Override public void validate() throws Validator.InvalidValueException { if (isRequired() && isEmpty()) { throw new Validator.EmptyValueException(requiredError); } validate(getFieldValue()); }
if (!isBuffered()) { if (committingValueToDataSource) { boolean propertyNotifiesOfTheBufferedValue = SharedUtil.equals( event.getProperty().getValue(), getInternalValue()); if (!propertyNotifiesOfTheBufferedValue) { readValueFromProperty(event); valueWasModifiedByDataSourceDuringCommit = true; } else if (!isModified()) { readValueFromProperty(event); fireValueChange(false);
/** * Retrieves a converter for the field from the converter factory defined * for the application. Clears the converter if no application reference is * available or if the factory returns null. * * @param datamodelType * The type of the data model that we want to be able to convert * from */ public void setConverter(Class<?> datamodelType) { Converter<T, ?> c = (Converter<T, ?>) ConverterUtil .getConverter(getType(), datamodelType, getSession()); setConverter(c); }
/** * Sets the converter used to convert the field value to property data * source type. The converter must have a presentation type that matches the * field type. * * @param converter * The new converter to use. * @return this (for method chaining) * @see AbstractField#setConverter(com.vaadin.v7.data.util.converter.Converter) */ public default S withConverter(Converter<T, ?> converter) { ((AbstractField<T>) this).setConverter(converter); return (S) this; }
/** * {@inheritDoc} * <p> * A Form is empty if all of its fields are empty. * */ @Override public boolean isEmpty() { for (Field<?> f : fields.values()) { if (f instanceof AbstractField) { if (!((AbstractField<?>) f).isEmpty()) { return false; } } } return true; }
@Override public boolean isRequired() { return component.isRequired(); }
@Override public void focus() { if (getFocusable() != null) { getFocusable().focus(); } else { super.focus(); } }
protected void commit() { component.commit(); }
protected void discard() { component.discard(); }
protected boolean isBuffered() { return component.isBuffered(); }