/** * Setup of the binding between view model and the UI controls. */ private void setupBinding() { dpDate.valueProperty().bindBidirectional(exerciseViewModel.date); // use comment formatter for time values => makes sure that the value is also valid final TextFormatter<LocalTime> timeTextFormatter = new TextFormatter<>(new TimeToStringConverter()); timeTextFormatter.valueProperty().bindBidirectional(exerciseViewModel.time); tfTime.setTextFormatter(timeTextFormatter); cbSportType.valueProperty().bindBidirectional(exerciseViewModel.sportType); cbSportSubtype.valueProperty().bindBidirectional(exerciseViewModel.sportSubType); cbIntensity.valueProperty().bindBidirectional(exerciseViewModel.intensity); tfDistance.textProperty().bindBidirectional(exerciseViewModel.distance, new NumberStringConverter()); tfAvgSpeed.textProperty().bindBidirectional(exerciseViewModel.avgSpeed); tfDuration.textProperty().bindBidirectional(exerciseViewModel.duration, new TimeInSecondsToStringConverter()); tfAscent.textProperty().bindBidirectional(exerciseViewModel.ascent, new NumberStringConverter()); tfDescent.textProperty().bindBidirectional(exerciseViewModel.descent, new NumberStringConverter()); tfAvgHeartrate.textProperty().bindBidirectional(exerciseViewModel.avgHeartRate, new NumberStringConverter()); tfCalories.textProperty().bindBidirectional(exerciseViewModel.calories, new NumberStringConverter()); cbEquipment.valueProperty().bindBidirectional(exerciseViewModel.equipment); tfHrmFile.textProperty().bindBidirectional(exerciseViewModel.hrmFile); taComment.textProperty().bindBidirectional(exerciseViewModel.comment); }
if (((ICountableElements) content).elementsCountProperty() != null) { SimpleIntegerProperty count = ((ICountableElements) content).elementsCountProperty(); this.count.textProperty().bindBidirectional(count, new NumberStringConverter()); label.setText(((ICountableElements) content).labelProperty().get());
speedLabel.textProperty().bindBidirectional(speed.valueProperty(), new NumberStringConverter("0.0 x"));
@Override protected void setupDialogControls() { laWeightUnit.setText(context.getFormatUtils().getWeightUnitName()); // setup binding between view model and the UI controls dpDate.valueProperty().bindBidirectional(weightViewModel.date); // use text formatter for time values => makes sure that the value is also valid final TextFormatter<LocalTime> timeTextFormatter = new TextFormatter<>(new TimeToStringConverter()); timeTextFormatter.valueProperty().bindBidirectional(weightViewModel.time); tfTime.setTextFormatter(timeTextFormatter); tfValue.textProperty().bindBidirectional(weightViewModel.value, new NumberStringConverter()); taComment.textProperty().bindBidirectional(weightViewModel.comment); FxWorkarounds.fixDatePickerTextEntry(dpDate); // setup validation of the UI controls // => due to a ControlsFX bug the validation setup must be executed after the dialog has been shown // (see https://bitbucket.org/controlsfx/controlsfx/issues/539/multiple-dialog-fields-with-validation ) Platform.runLater(() -> { validationSupport.registerValidator(dpDate, Validator.createEmptyValidator(context.getResources().getString("st.dlg.weight.error.date"))); validationSupport.registerValidator(tfTime, // Validator.createEmptyValidator(context.getResources().getString("st.dlg.weight.error.time"))); validationSupport.registerValidator(tfValue, true, (Control control, String newValue) -> ValidationResult .fromErrorIf(tfValue, context.getResources().getString("st.dlg.weight.error.weight"), !ValidationUtils.isValueDoubleBetween(newValue, 0.1d, 1000))); }); }