List of usage examples for javafx.beans.binding Bindings bindBidirectional
public static <T> void bindBidirectional(Property<String> stringProperty, Property<T> otherProperty, StringConverter<T> converter)
From source file:caillou.company.clonemanager.gui.customComponent.statistic.StatisticHelper.java
private static List<Node> createStaticDoublonList() { List<Node> results = new ArrayList<>(); // Number of file scanned LoadingMojo loadingMojoFilesScanned = SpringFxmlLoader.load(Navigation.STATISTIC_COMPONENT); StatisticController statisticControllerFilesScanned = (StatisticController) loadingMojoFilesScanned .getController();/* w w w .j a va2 s .c o m*/ statisticControllerFilesScanned.setImage(Image.SCANNED_FILES); statisticControllerFilesScanned .setStaticText(SpringFxmlLoader.getResourceBundle().getString("statistic.text.scannedFileNumber")); statisticControllerFilesScanned.dynamicTextProperty() .bind(mainModel.getSearchStatisticsModel().nbScannedFilesProperty().asString()); results.add(loadingMojoFilesScanned.getParent()); // Space wasted LoadingMojo loadingMojoWastedSpace = SpringFxmlLoader.load(Navigation.STATISTIC_COMPONENT); StatisticController statisticControllerWastedSpace = (StatisticController) loadingMojoWastedSpace .getController(); statisticControllerWastedSpace.setImage(Image.WASTED_SPACE); statisticControllerWastedSpace .setStaticText(SpringFxmlLoader.getResourceBundle().getString("statistic.text.wastedSpace")); Bindings.bindBidirectional(statisticControllerWastedSpace.dynamicTextProperty(), mainModel.getSearchStatisticsModel().spaceWastedProperty(), new ByteStringConverter()); results.add(loadingMojoWastedSpace.getParent()); // Number of file duplicated LoadingMojo loadingMojoNumberDuplicated = SpringFxmlLoader.load(Navigation.STATISTIC_COMPONENT); StatisticController statisticControllerNumberDuplicated = (StatisticController) loadingMojoNumberDuplicated .getController(); statisticControllerNumberDuplicated.setImage(Image.FILES_DUPLICATED); statisticControllerNumberDuplicated.setStaticText( SpringFxmlLoader.getResourceBundle().getString("statistic.text.duplicatedFileNumber")); statisticControllerNumberDuplicated.dynamicTextProperty() .bind(mainModel.getSearchStatisticsModel().nbDuplicateFilesProperty().asString()); results.add(loadingMojoNumberDuplicated.getParent()); // Space released LoadingMojo loadingMojoSpaceReleased = SpringFxmlLoader.load(Navigation.STATISTIC_COMPONENT); StatisticController statisticControllerSpaceReleased = (StatisticController) loadingMojoSpaceReleased .getController(); statisticControllerSpaceReleased.setImage(Image.GARBAGE); statisticControllerSpaceReleased .setStaticText(SpringFxmlLoader.getResourceBundle().getString("statistic.text.spaceFreedUp")); Bindings.bindBidirectional(statisticControllerSpaceReleased.dynamicTextProperty(), mainModel.getSearchStatisticsModel().spaceReleasedProperty(), new ByteStringConverter()); results.add(loadingMojoSpaceReleased.getParent()); return results; }
From source file:caillou.company.clonemanager.gui.customComponent.statistic.StatisticHelper.java
private static List<Node> createStaticMissingList() { List<Node> results = new ArrayList<>(); // Number of file scanned LoadingMojo loadingMojo = SpringFxmlLoader.load(Navigation.STATISTIC_COMPONENT); StatisticController statisticController = (StatisticController) loadingMojo.getController(); statisticController.setImage(Image.SCANNED_FILES); statisticController/*w ww.j a v a2 s .c o m*/ .setStaticText(SpringFxmlLoader.getResourceBundle().getString("statistic.text.scannedFileNumber")); statisticController.dynamicTextProperty() .bind(mainModel.getSearchStatisticsModel().nbScannedFilesProperty().asString()); results.add(loadingMojo.getParent()); // Amount of space to copy LoadingMojo loadingMojoWastedSpace = SpringFxmlLoader.load(Navigation.STATISTIC_COMPONENT); StatisticController statisticControllerWastedSpace = (StatisticController) loadingMojoWastedSpace .getController(); statisticControllerWastedSpace.setImage(Image.WASTED_SPACE); statisticControllerWastedSpace .setStaticText(SpringFxmlLoader.getResourceBundle().getString("statistic.text.spaceToCopy")); Bindings.bindBidirectional(statisticControllerWastedSpace.dynamicTextProperty(), mainModel.getSearchStatisticsModel().spaceToDuplicateProperty(), new ByteStringConverter()); results.add(loadingMojoWastedSpace.getParent()); // Number of file to duplicate LoadingMojo loadingMojoNumberToDuplicate = SpringFxmlLoader.load(Navigation.STATISTIC_COMPONENT); StatisticController statisticControllerNumberToDuplicate = (StatisticController) loadingMojoNumberToDuplicate .getController(); statisticControllerNumberToDuplicate.setImage(Image.FILES_DUPLICATED); statisticControllerNumberToDuplicate.setStaticText( SpringFxmlLoader.getResourceBundle().getString("statistic.text.numberOfFileToDuplicate")); statisticControllerNumberToDuplicate.dynamicTextProperty() .bind(mainModel.getSearchStatisticsModel().nbFileToDuplicateProperty().asString()); results.add(loadingMojoNumberToDuplicate.getParent()); return results; }
From source file:ambroafb.clients.dialog.ClientDialogController.java
@Override protected void makeExtraActions(EDITOR_BUTTON_TYPE buttonType) { openDate.setDisable(true);/*from www. ja v a 2 s . c o m*/ boolean editable = true; if (buttonType.equals(EDITOR_BUTTON_TYPE.VIEW) || buttonType.equals(EDITOR_BUTTON_TYPE.DELETE)) { editable = false; } Client client = (Client) sceneObj; // if (client != null){ PhoneComboBox phonesCombobox = new PhoneComboBox(client.getPhones(), editable); phonesContainer.getChildren().add(phonesCombobox); if (!buttonType.equals(EDITOR_BUTTON_TYPE.ADD) && (client.getEmail() == null || client.getEmail().isEmpty())) { email.setDisable(true); } if (client.getIsJur()) { changeSceneVisualAsFirm(" "); } imageGalleryController.setURLData(serviceURLPrefix, client.getRecId() + "/", client.getRecId() + "/all"); List<String> imageNames = client.getDocuments().stream().map((Client.Document doc) -> doc.path) .collect(Collectors.toList()); imageGalleryController.downloadData(imageNames); client.setClientImageGallery(imageGalleryController); Consumer<ObservableList<ClientStatus>> setStatusById = (statusList) -> { Integer statusId = client.getStatusId(); Bindings.bindBidirectional(client.statusIdProperty(), statuses.valueProperty(), new StatusToIdBiConverter()); client.statusDescripProperty() .bind(Bindings.createStringBinding( () -> (statuses.getValue() == null) ? null : "" + statuses.getValue().getDescrip(), statuses.valueProperty())); statusProperty.bind(statuses.valueProperty()); client.setStatusId(statusId); }; statuses.fillComboBox(setStatusById); Consumer<ObservableList<Country>> setCountryById = (countryList) -> { Integer countryId = client.getCountryId(); Bindings.bindBidirectional(client.countryIdProperty(), country.valueProperty(), new CountryToIdBiConverter()); client.countryCodeProperty() .bind(Bindings.createStringBinding( () -> (country.getValue() == null) ? null : "" + country.getValue().getCode(), country.valueProperty())); client.setCountryId(countryId); }; country.fillComboBoxWithoutALL(setCountryById); // } }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private void addRowFees(final Pane content, final BookingBean be) { final HBox box = new HBox(); // configure box box.setSpacing(8);/*from w w w.j av a 2 s . c om*/ box.setPadding(boxPadding); box.setAlignment(Pos.CENTER); box.setFillHeight(true); // add cleaning fees final TextField cleaningFeesTextField = new TextField(); Bindings.bindBidirectional(cleaningFeesTextField.textProperty(), be.cleaningFeesProperty(), new NumberStringConverter(decimalFormat)); cleaningFeesTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow cleaningFeesTextFlow = new TextFlow(new Text("Cleaning Fees: "), cleaningFeesTextField, new Text(" ")); box.getChildren().add(cleaningFeesTextFlow); // add cleaning costs final CleaningEntry ce = be.getCleaning(); if (ce != null) { final TextField cleaningCostsTextField = new TextField(); Bindings.bindBidirectional(cleaningCostsTextField.textProperty(), ce.cleaningCostsProperty(), new NumberStringConverter(decimalFormat)); cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "), cleaningCostsTextField, new Text(" ")); box.getChildren().add(cleaningCostsTextFlow); } else { final TextField cleaningCostsTextField = new TextField("No Cleaning"); cleaningCostsTextField.setEditable(false); cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "), cleaningCostsTextField); cleaningCostsTextField.getStyleClass().add("warning"); box.getChildren().add(cleaningCostsTextFlow); } // add service fees final TextField serviceFeesTextField = new TextField(); Bindings.bindBidirectional(serviceFeesTextField.textProperty(), be.serviceFeeProperty(), new NumberStringConverter(decimalFormat)); serviceFeesTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow serviceFeesAbsTextFlow = new TextFlow(new Text("Service Fees: "), serviceFeesTextField, new Text(" ")); box.getChildren().add(serviceFeesAbsTextFlow); // add service fees percent final TextField serviceFeesPercentTextField = new TextField(); Bindings.bindBidirectional(serviceFeesPercentTextField.textProperty(), be.serviceFeesPercentProperty(), new NumberStringConverter(decimalFormat)); serviceFeesPercentTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow serviceFeesPercentTextFlow = new TextFlow(new Text("Service Fees: "), serviceFeesPercentTextField, new Text(" %")); box.getChildren().add(serviceFeesPercentTextFlow); // add box to parent content.getChildren().add(box); }
From source file:UI.MainStageController.java
/** * initializes the bindings of the sliders and the analysis pane */// w w w .ja v a2 s .com private void initializeBindings() { //First, bind the LoadedData.analyzeAll boolean property to the radio buttons LoadedData.analyzeSelectedProperty().bind(compareSelectedSamplesButton.selectedProperty()); //Since the slider value property is double and the text field property is a string, we need to convert them //Defining own class to avoid exceptions class MyNumberStringConverter extends NumberStringConverter { @Override public Number fromString(String value) { try { return super.fromString(value); } catch (RuntimeException ex) { return 0; } } } StringConverter<Number> converter = new MyNumberStringConverter(); //Bind every slider to its corresponding text field and vice versa Bindings.bindBidirectional(minPosCorrelationText.textProperty(), posCorrelationRangeSlider.lowValueProperty(), converter); Bindings.bindBidirectional(maxPosCorrelationText.textProperty(), posCorrelationRangeSlider.highValueProperty(), converter); Bindings.bindBidirectional(minNegCorrelationText.textProperty(), negCorrelationRangeSlider.lowValueProperty(), converter); Bindings.bindBidirectional(maxNegCorrelationText.textProperty(), negCorrelationRangeSlider.highValueProperty(), converter); Bindings.bindBidirectional(maxPValueText.textProperty(), maxPValueSlider.valueProperty(), converter); Bindings.bindBidirectional(minFrequencyText.textProperty(), frequencyRangeSlider.lowValueProperty(), converter); Bindings.bindBidirectional(maxFrequencyText.textProperty(), frequencyRangeSlider.highValueProperty(), converter); Bindings.bindBidirectional(excludeFrequencyText.textProperty(), excludeFrequencySlider.valueProperty(), converter); //Bind the internal filter properties to the slider values AnalysisData.posCorrelationLowerFilterProperty().bind(posCorrelationRangeSlider.lowValueProperty()); AnalysisData.posCorrelationUpperFilterProperty().bind(posCorrelationRangeSlider.highValueProperty()); AnalysisData.negCorrelationLowerFilterProperty().bind(negCorrelationRangeSlider.lowValueProperty()); AnalysisData.negCorrelationUpperFilterProperty().bind(negCorrelationRangeSlider.highValueProperty()); AnalysisData.minFrequencyProperty().bind(frequencyRangeSlider.lowValueProperty()); AnalysisData.maxFrequencyProperty().bind(frequencyRangeSlider.highValueProperty()); AnalysisData.maxPValueProperty().bind(maxPValueSlider.valueProperty()); AnalysisData.excludeFrequencyThresholdProperty().bind(excludeFrequencySlider.valueProperty()); //The values of the negative slider can't be set to values below 0 via FXML for reasons beyond human understanding, // so we set them manually negCorrelationRangeSlider.setLowValue(-1); negCorrelationRangeSlider.setHighValue(-0.5); //We want the graph to be redone if one of the following occurs: //1. Radio button switches between "Analyze All" and "Analyze Selected" compareSelectedSamplesButton.selectedProperty().addListener(observable -> { if ((!compareSelectedSamplesButton.isSelected() || LoadedData.getSelectedSamples().size() >= 3) && rankChoiceBox.getValue() != null) startAnalysis(); }); //2. Rank selection changes rankChoiceBox.valueProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null && LoadedData.getSamplesToAnalyze().size() >= 3) { AnalysisData.setLevel_of_analysis(newValue.toLowerCase()); startAnalysis(); } }); //3. Sample selection changes while "Analyze Selected" is selected AND at least three samples are selected LoadedData.getSelectedSamples().addListener((InvalidationListener) observable -> { if (compareSelectedSamplesButton.isSelected() && LoadedData.getSelectedSamples().size() >= 3) { startAnalysis(); } }); //4. Correlation radio button is changed pearsonCorrelationButton.selectedProperty().addListener(o -> startAnalysis()); spearmanCorrelationButton.selectedProperty().addListener(o -> startAnalysis()); kendallCorrelationButton.selectedProperty().addListener(o -> startAnalysis()); //5. Global frequency threshold is changed excludeFrequencySlider.valueProperty().addListener(o -> startAnalysis()); }