List of usage examples for javafx.beans.binding LongBinding LongBinding
LongBinding
From source file:caillou.company.clonemanager.gui.customComponent.critere.CritereController.java
@Override public void initialize(URL url, ResourceBundle rb) { mainModel.getCritereModel().getFormat().allProperty().bind(formatAllId.selectedProperty()); mainModel.getCritereModel().getFormat().videoProperty().bind( Bindings.and(formatVideoId.selectedProperty(), Bindings.not(formatVideoId.disableProperty()))); mainModel.getCritereModel().getFormat().audioProperty().bind( Bindings.and(formatAudioId.selectedProperty(), Bindings.not(formatAudioId.disableProperty()))); mainModel.getCritereModel().getFormat().imageProperty().bind( Bindings.and(formatImageId.selectedProperty(), Bindings.not(formatImageId.disableProperty()))); mainModel.getCritereModel().getFormat().archiveProperty().bind( Bindings.and(formatArchiveId.selectedProperty(), Bindings.not(formatArchiveId.disableProperty()))); LongBinding minimumSizeComputationBinding = new LongBinding() { {// w w w . j a v a 2s . c om super.bind(minimumSizeFormatId.valueProperty(), sizeMinId.valueProperty()); } @Override protected long computeValue() { if (minimumSizeFormatId.getValue().equals("octet")) { return (long) sizeMinId.valueProperty().get() * 1; } if (minimumSizeFormatId.getValue().equals("kilo octet")) { return (long) sizeMinId.valueProperty().get() * 1000; } if (minimumSizeFormatId.getValue().equals("mega octet")) { return (long) sizeMinId.valueProperty().get() * 1000000; } if (minimumSizeFormatId.getValue().equals("giga octet")) { return (long) sizeMinId.valueProperty().get() * 1000000000; } throw new IllegalArgumentException("Unkowned size format"); } }; mainModel.getCritereModel().getSize().minimalSizeProperty().bind(minimumSizeComputationBinding); LongBinding maximumSizeComputationBinding = new LongBinding() { { super.bind(maximumSizeFormatId.valueProperty(), sizeMaxId.valueProperty()); } @Override protected long computeValue() { if (maximumSizeFormatId.getValue().equals("octet")) { return (long) sizeMaxId.valueProperty().get() * 1; } if (maximumSizeFormatId.getValue().equals("kilo octet")) { return (long) sizeMaxId.valueProperty().get() * 1000; } if (maximumSizeFormatId.getValue().equals("mega octet")) { return (long) sizeMaxId.valueProperty().get() * 1000000; } if (maximumSizeFormatId.getValue().equals("giga octet")) { return (long) sizeMaxId.valueProperty().get() * 1000000000; } throw new IllegalArgumentException("Unkowned size format"); } }; mainModel.getCritereModel().getSize().minimalSizeProperty().bind(minimumSizeComputationBinding); mainModel.getCritereModel().getSize().maximalSizeProperty().bind(maximumSizeComputationBinding); formatAllId.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { disableEnableCheckboxes(newValue); if (newValue) { formatVideoId.setSelected(false); formatAudioId.setSelected(false); formatImageId.setSelected(false); formatArchiveId.setSelected(false); } } }); }