private static void setSpinnerBehaviour( final IntegerSpinnerValueFactory svf, final boolean useDefaultValue, final ObservableIntegerValue defaultValue, final ObjectProperty<Integer> customValue ) { if (useDefaultValue) { svf.valueProperty().unbindBidirectional(customValue); svf.setValue(defaultValue.get()); } else { svf.setValue(customValue.getValue()); svf.valueProperty().bindBidirectional(customValue); } } }
@Override protected Node createUndecoratedEditor() { final CheckBox cbNull = new CheckBox(); final Node wrappedCb = ItemUtil.lockDecorator(cbNull, document, ItemUtil.DATABASE_RELATION_TOOLTIP); final Label label = new Label(IMPLEMENTATION_TITLE); final ChoiceBox<ImplementAs> cbImpl = new ChoiceBox<>( observableArrayList(ImplementAs.values()) ); cbImpl.setTooltip(new Tooltip(IMPLEMENTATION_TOOLTIP)); final HBox right = new HBox(label, cbImpl); final HBox left = new HBox(wrappedCb, right); left.setSpacing(16); right.setSpacing(8); right.setAlignment(Pos.CENTER); cbNull.selectedProperty().bindBidirectional(nullable); cbImpl.valueProperty().bindBidirectional(implementation); right.visibleProperty().bind(nullable); right.disableProperty().bind(nullable.not()); return left; }
@Override public void bindBidirectional(Property<T> other) { delegate.bindBidirectional(other); }
@PostConstruct private void initializeBinding() { portSceneHandler.currentSceneProperty().bindBidirectional(currentScene); marketSceneHandler.currentSceneProperty().bindBidirectional(currentScene); shipyardSceneHandler.currentSceneProperty().bindBidirectional(currentScene); tavernSceneHandler.currentSceneProperty().bindBidirectional(currentScene); cityHallSceneEventHandler.currentSceneProperty().bindBidirectional(currentScene); loanerSceneEventHandler.currentSceneProperty().bindBidirectional(currentScene); churchSceneEventHandler.currentSceneProperty().bindBidirectional(currentScene); seamapSceneEventHandler.currentSceneProperty().bindBidirectional(currentScene); guildSceneEventHandler.currentSceneProperty().bindBidirectional(currentScene); armorySceneEventHandler.currentSceneProperty().bindBidirectional(currentScene); } public ObjectProperty<EScene> currentSceneProperty() {
/** * Binds the given items and selection property with the corresponding * elements. * * @param itemsBinding * The items property to be bound with. * * @param selectionBinding * The selection property to be bound with. * * @return Returns the current field to allow for chaining. */ public SingleSelectionField<V> bind(ListProperty<V> itemsBinding, ObjectProperty<V> selectionBinding) { items.bindBidirectional(itemsBinding); selection.bindBidirectional(selectionBinding); return this; }
public static <T extends Enum<T>> ComboBox<T> bindEnumCombo(@Nonnull ComboBox<T> combo, @Nonnull ObjectProperty<T> property, @Nonnull ObservableList<T> items) { combo.itemsProperty().set(items); combo.valueProperty().bindBidirectional(property); return combo; }
@Override public Node createValueVisualisation() { ColorPicker colorPicker = new ColorPicker(); colorPicker.valueProperty().bindBidirectional(observableAttributeValue); return colorPicker; } }
@Nonnull public static <T extends Enum<T>> ComboBox<T> bindEnumComboSpecificEnums(@Nonnull ComboBox<T> combo, @Nonnull ObjectProperty<T> property, @Nonnull Class<T> type, @Nonnull T[] enumConstants) { combo.itemsProperty().set(FXCollections.observableArrayList(enumConstants)); combo.valueProperty().bindBidirectional(property); combo.setButtonCell(new EnumListCell<>()); combo.setCellFactory(param -> new EnumListCell<>()); return combo; }
@Override public Node createValueVisualisation() { DatePicker datePicker = new DatePicker(); datePicker.valueProperty().bindBidirectional(observableAttributeValue); datePicker.disableProperty().bind(readOnly); return datePicker; } }
/** * Setup of the binding between view model and the UI controls. */ private void setupBinding() { dpStart.valueProperty().bindBidirectional(filterViewModel.dateStart); dpEnd.valueProperty().bindBidirectional(filterViewModel.dateEnd); cbSportType.valueProperty().bindBidirectional(filterViewModel.sportType); cbSportSubtype.valueProperty().bindBidirectional(filterViewModel.sportSubtype); cbIntensity.valueProperty().bindBidirectional(filterViewModel.intensity); cbEquipment.valueProperty().bindBidirectional(filterViewModel.equipment); tfComment.textProperty().bindBidirectional(filterViewModel.commentSubString); cbRegExpression.selectedProperty().bindBidirectional(filterViewModel.regularExpressionMode); rbTypeExercise.setUserData(EntryFilter.EntryType.EXERCISE); rbTypeNote.setUserData(EntryFilter.EntryType.NOTE); rbTypeWeight.setUserData(EntryFilter.EntryType.WEIGHT); BindingUtils.bindToggleGroupToProperty(tgEntryType, filterViewModel.entryType); BooleanBinding entryTypeSelectionDisabled = Bindings.not(filterViewModel.entryTypeSelectable); rbTypeExercise.disableProperty().bind(entryTypeSelectionDisabled); rbTypeNote.disableProperty().bind(entryTypeSelectionDisabled); rbTypeWeight.disableProperty().bind(entryTypeSelectionDisabled); }
public void updateColorControls() { Type type = currentCssConfig.getType(); unbindColorProperties(); if(type == Type.CSS) { cssUrlGroup.setVisible(true); cssColorGroup.setVisible(false); cssUrl.setText(currentCssConfig.getCssUrl()); } else { cssColorGroup.setVisible(true); cssUrlGroup.setVisible(false); ObjectProperty<Color>[] props = currentCssConfig.getColorProperties(); picker1.valueProperty().bindBidirectional(props[0]); picker2.valueProperty().bindBidirectional(props[1]); picker3.valueProperty().bindBidirectional(props[2]); refreshPickers(); } }
private HBox createYearMonthChooser() { final HBox hBox = new HBox(3); hBox.setAlignment(Pos.CENTER_LEFT); final ComboBox<Integer> months = new ComboBox<Integer>(); months.setConverter(new IntegerStringConverter()); months.valueProperty().bindBidirectional(model.month); months.setEditable(true); for (int i = 0; i < 12; i++) { months.getItems().add(i + 1); } final ComboBox<Integer> years = new ComboBox<Integer>(); for (int i = 1970; i < 2100; i++) { years.getItems().add(i); } years.valueProperty().bindBidirectional(model.year); years.setEditable(true); years.setConverter(new IntegerStringConverter()); hBox.getChildren().add(new Label("Date")); hBox.getChildren().add(months); hBox.getChildren().add(years); VBox.setMargin(hBox, new Insets(3)); return hBox; }
@Override public Node createValueVisualisation() { comboBox = new ComboBox<>(); comboBox.getItems().add(0, null); comboBox.getItems().addAll(possibleValuesProvider.get()); comboBox.valueProperty().bindBidirectional(observableAttributeValue); comboBox.setEditable(false); comboBox.disableProperty().bind(readOnly); comboBox.setConverter(new StringConverter<>() { @Override public String toString(T object) { return object == null ? "" : object.internal().getDisplayText(); } @Override public T fromString(String string) { throw new UnsupportedOperationException(); } }); comboBox.setMinWidth(300); return comboBox; } }
/** * 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); }
private static void setSpinnerBehaviour( final IntegerSpinnerValueFactory svf, final boolean useDefaultValue, final ObservableIntegerValue defaultValue, final ObjectProperty<Integer> customValue ) { if (useDefaultValue) { svf.valueProperty().unbindBidirectional(customValue); svf.setValue(defaultValue.get()); } else { svf.setValue(customValue.getValue()); svf.valueProperty().bindBidirectional(customValue); } } }
@Override public Node createValueVisualisation() { ComboBox<Locale> comboBox=new ComboBox<>(); comboBox.setConverter(new StringConverter<>() { @Override public String toString(Locale locale) { if (locale!=null){ return locale.getDisplayName(); } return ""; } @Override public Locale fromString(String string) { return null; } }); comboBox.getItems().addAll(DateFormat.getAvailableLocales()); comboBox.valueProperty().bindBidirectional(observableAttributeValue); return comboBox; } }
@Override protected void setupDialogControls() { // setup binding between view model and the UI controls dpDate.valueProperty().bindBidirectional(noteViewModel.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(noteViewModel.time); tfTime.setTextFormatter(timeTextFormatter); taText.textProperty().bindBidirectional(noteViewModel.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.note.error.date"))); validationSupport.registerValidator(tfTime, // Validator.createEmptyValidator(context.getResources().getString("st.dlg.note.error.time"))); validationSupport.registerValidator(taText, // Validator.createEmptyValidator(context.getResources().getString("st.dlg.note.error.no_text"))); }); }
@Override @SuppressWarnings("unchecked") public Node createValueVisualisation() { ComboBox<E> comboBox = new ComboBox<>(); comboBox.setEditable(false); comboBox.getItems().addAll(possibleEnumConstants); comboBox.valueProperty().bindBidirectional(observableAttributeValue); comboBox.setConverter(stringConverter); Button deleteButton = new Button(); uniformDesign.addDangerIcon(deleteButton, FontAwesome.Glyph.TIMES); deleteButton.setOnAction(event -> observableAttributeValue.set(null)); deleteButton.disableProperty().bind(observableAttributeValue.isNull());//.or(Bindings.createBooleanBinding(()-> isReadOnlyVisualisation))); HBox hbox = new HBox(3); hbox.getChildren().addAll(comboBox,deleteButton); hbox.disableProperty().bind(readOnly); return hbox; } }
@Override protected Node createUndecoratedEditor() { final CheckBox cbNull = new CheckBox(); final Node wrappedCb = ItemUtil.lockDecorator(cbNull, document, ItemUtil.DATABASE_RELATION_TOOLTIP); final Label label = new Label(IMPLEMENTATION_TITLE); final ChoiceBox<ImplementAs> cbImpl = new ChoiceBox<>( observableArrayList(ImplementAs.values()) ); cbImpl.setTooltip(new Tooltip(IMPLEMENTATION_TOOLTIP)); final HBox right = new HBox(label, cbImpl); final HBox left = new HBox(wrappedCb, right); left.setSpacing(16); right.setSpacing(8); right.setAlignment(Pos.CENTER); cbNull.selectedProperty().bindBidirectional(nullable); cbImpl.valueProperty().bindBidirectional(implementation); right.visibleProperty().bind(nullable); right.disableProperty().bind(nullable.not()); return left; }
@Override protected void setupDialogControls() { setupSelectionControls(); // setup binding between view model and the UI controls // (validation is not needed here) BindingUtils.bindToggleGroupToProperty(tgInitialView, preferencesViewModel.initialView); cbAutomaticCalculation.valueProperty().bindBidirectional(preferencesViewModel.defaultAutoCalculation); cbSaveOnExit.selectedProperty().bindBidirectional(preferencesViewModel.saveOnExit); BindingUtils.bindToggleGroupToProperty(tgUnitSystem, preferencesViewModel.unitSystem); BindingUtils.bindToggleGroupToProperty(tgSpeedMode, preferencesViewModel.preferredSpeedMode); BindingUtils.bindToggleGroupToProperty(tgWeekStart, preferencesViewModel.weekStart); cbOptionalAvgHeartrate.selectedProperty().bindBidirectional(preferencesViewModel.listViewShowAvgHeartrate); cbOptionalAscent.selectedProperty().bindBidirectional(preferencesViewModel.listViewShowAscent); cbOptionalDescent.selectedProperty().bindBidirectional(preferencesViewModel.listViewShowDescent); cbOptionalEnergy.selectedProperty().bindBidirectional(preferencesViewModel.listViewShowEnergy); cbOptionalEquipment.selectedProperty().bindBidirectional(preferencesViewModel.listViewShowEquipment); cbOptionalComment.selectedProperty().bindBidirectional(preferencesViewModel.listViewShowComment); cbDiagramTwoGraphs.selectedProperty().bindBidirectional(preferencesViewModel.evDisplaySecondChart); cbDiagramSmoothedCharts.selectedProperty().bindBidirectional(preferencesViewModel.evDisplaySmoothedCharts); }