/** * Called when a new value is set to determine whether the provided new * value is considered to be a change compared to the current value. This is * used to determine whether {@link #doSetValue(Object)} should be called * and a value change event fired. * * @param newValue * the new value candidate to check, may be <code>null</code> * * @return <code>true</code> if the provided value is considered to be * different and a value change event should be fired; * <code>false</code> if the values are considered to be the same * and no value change should be fired */ protected boolean isDifferentValue(T newValue) { return !Objects.equals(newValue, getValue()); }
/** * Sets the value of this field if it has changed and fires a value change * event. If the value originates from the client and this field is * read-only, does nothing. Invokes {@link #doSetValue(Object) doSetValue} * to actually store the value. * * @param value * the new value to set * @param userOriginated * {@code true} if this event originates from the client, * {@code false} otherwise. * @return <code>true</code> if the value was updated, <code>false</code> * otherwise */ protected boolean setValue(T value, boolean userOriginated) { if (userOriginated && isReadOnly()) { return false; } if (!isDifferentValue(value)) { return false; } T oldValue = this.getValue(); doSetValue(value); if (!userOriginated) { markAsDirty(); } fireEvent(createValueChange(oldValue, userOriginated)); return true; }
protected Object getValueFromField() { return field.getValue(); }
@Override protected void setValueToDataSource(DataConnector data) throws MException { try { data.setBoolean((Boolean)field.getValue()); } catch (Throwable t) { } }
protected void setValueToDataSource(DataConnector data) throws MException { data.setString((String)field.getValue()); }
@Override protected void setValueToDataSource(DataConnector data) throws MException { data.setDate((Date)field.getValue()); }
@Override protected Object getValueFromDataSource(DataConnector data) throws MException { Object d = field.getValue(); if (d == null) return 0; try { return data.getNumber(Double.parseDouble(String.valueOf(d))); } catch (Throwable t) { return data.getNumber(0); } } }
private static Object getCurrentVaue(final Component currentChangedComponent, final Object newValue, final AbstractField<?> field) { Object currentValue = field.getValue(); if (field instanceof Table) { currentValue = ((Table) field).getContainerDataSource().getItemIds(); } if (field.equals(currentChangedComponent)) { currentValue = newValue; } return currentValue; }
private static Object getCurrentVaue(final Component currentChangedComponent, final Object newValue, final AbstractField<?> field) { Object currentValue = field.getValue(); if (field instanceof Table) { currentValue = ((Table) field).getContainerDataSource().getItemIds(); } if (field.equals(currentChangedComponent)) { currentValue = newValue; } return currentValue; }
/** * saves the original values in a Map so we can use them for detecting * changes */ public final void setOrginaleValues() { for (final AbstractField<?> field : allComponents) { Object value = field.getValue(); if (field instanceof Table) { value = ((Table) field).getContainerDataSource().getItemIds(); } orginalValues.put(field, value); } saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(null, null)); }
/** * saves the original values in a Map so we can use them for detecting * changes */ public final void setOrginaleValues() { for (final AbstractField<?> field : allComponents) { Object value = field.getValue(); if (field instanceof Table) { value = ((Table) field).getContainerDataSource().getItemIds(); } orginalValues.put(field, value); } saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(null, null)); }
optionBinder.bindOption(key, field); setFieldMetaData(key, field); log.debug("option field {} value is at {}", field.getCaption(), field.getValue()); Button defaultsButton = new Button(translate.from(LabelKey.Reset_to_Default)); Optional<String> optionKeyName = Optional.of(((Enum) key.getKey()).name());
setFieldValue(uiField, value); uiField.addValueChangeListener(event -> { option.set(key, uiField.getValue()); context.optionValueChanged(event); });