private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); String text = textField.getText(); try { hasErrors.set(false); if (!text.isEmpty()) numberStringConverter.fromString(text); } catch (Exception e) { hasErrors.set(true); } }
private void goToTime(LocalTime time) { if (time != null) { int hour = time.getHour(); selectedHourLabel.setText(Integer.toString(hour % (is24HourView ? 24 : 12) == 0 ? (is24HourView ? 0 : 12) : hour % (is24HourView ? 24 : 12))); selectedMinLabel.setText(unitConverter.toString(time.getMinute())); if (!is24HourView) { period.set(hour < 12 ? "AM" : "PM"); } minsPointerRotate.setAngle(180 + (time.getMinute() + 45) % 60 * Math.toDegrees(2 * Math.PI / 60)); hoursPointerRotate.setAngle(180 + Math.toDegrees(2 * (hour - 3) * Math.PI / 12)); _24HourHoursPointerRotate.setAngle(180 + Math.toDegrees(2 * (hour - 3) * Math.PI / 12)); } }
/** * 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());
@Override public Number fromString(String value) { if ("-".equals(value)) { return 0.0; } return super.fromString(value); }
speedLabel.textProperty().bindBidirectional(speed.valueProperty(), new NumberStringConverter("0.0 x"));
StackPane labelContainer = new StackPane(); int val = ((i + 3) * 5) % 60; Label label = new Label(String.valueOf(unitConverter.toString(val))); label.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12));
@Override public Number fromString(String value) { if ("-".equals(value)) { return 0; } return super.fromString(value); } }
@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))); }); }
timeLabel.set(selectedHourLabel); selectedMinLabel.setText(String.valueOf(unitConverter.toString(time.getMinute()))); selectedMinLabel.getStyleClass().add(SPINNER_LABEL); selectedMinLabel.setTextFill(fadedColor);
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); String text = textField.getText(); try { hasErrors.set(false); if (!text.isEmpty()) numberStringConverter.fromString(text); } catch (Exception e) { hasErrors.set(true); } }
timeValue = (index + 45) % 60; timeLabel.get().setText(unit.get() == TimeUnit.MINUTES ? unitConverter.toString(timeValue) : Integer.toString(timeValue)); updateValue(); };
Number controlNewValue = converter.fromString(change.getControlNewText()); if (!filter.test(controlNewValue)) { return null;
private void goToTime(LocalTime time) { if (time != null) { int hour = time.getHour(); selectedHourLabel.setText(Integer.toString(hour % (is24HourView ? 24 : 12) == 0 ? (is24HourView ? 0 : 12) : hour % (is24HourView ? 24 : 12))); selectedMinLabel.setText(unitConverter.toString(time.getMinute())); if (!is24HourView) { period.set(hour < 12 ? "AM" : "PM"); } minsPointerRotate.setAngle(180 + (time.getMinute() + 45) % 60 * Math.toDegrees(2 * Math.PI / 60)); hoursPointerRotate.setAngle(180 + Math.toDegrees(2 * (hour - 3) * Math.PI / 12)); _24HourHoursPointerRotate.setAngle(180 + Math.toDegrees(2 * (hour - 3) * Math.PI / 12)); } }
StackPane labelContainer = new StackPane(); int val = ((i + 3) * 5) % 60; Label label = new Label(String.valueOf(unitConverter.toString(val))); label.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12));
timeLabel.set(selectedHourLabel); selectedMinLabel.setText(String.valueOf(unitConverter.toString(time.getMinute()))); selectedMinLabel.getStyleClass().add(SPINNER_LABEL); selectedMinLabel.setTextFill(fadedColor);
timeValue = (index + 45) % 60; timeLabel.get().setText(unit.get() == TimeUnit.MINUTES ? unitConverter.toString(timeValue) : Integer.toString(timeValue)); updateValue(); };