List of usage examples for javafx.beans.binding Bindings greaterThan
public static BooleanBinding greaterThan(String op1, final ObservableStringValue op2)
From source file:sonicScream.controllers.CategoryTabController.java
public CategoryTabController(Category category) { URL location = getClass().getResource("/sonicScream/views/CategoryTab.fxml"); FXMLLoader loader = new FXMLLoader(location); loader.setRoot(this); loader.setController(this); try {//from ww w . jav a2s . c o m loader.load(); } catch (IOException ex) { throw new RuntimeException(ex); } _category = category; this.textProperty().bind(_category.categoryNameProperty()); CategoryTabComboBox.setItems(_category.getCategoryScripts()); //These two bindings handle changing between categories with only a single //script (items) and those with multiple (everything else) SimpleListProperty bindableList = new SimpleListProperty(); bindableList.bind(new SimpleObjectProperty<>(_category.getCategoryScripts())); CategoryTabComboBox.visibleProperty().bind(Bindings.greaterThan(bindableList.sizeProperty(), 1)); selectedScriptNodeProperty().bind(CategoryTabTreeView.getSelectionModel().selectedItemProperty()); selectedScript.bind(CategoryTabComboBox.getSelectionModel().selectedItemProperty()); if (_category.getCategoryScripts() != null && !_category.getCategoryScripts().isEmpty()) { CategoryTabComboBox.valueProperty().set(_category.getCategoryScripts().get(0)); handleComboBoxChanged(null); } SwapDisplayModeButton.textProperty().bind(Bindings.when(displayMode.isEqualTo(CategoryDisplayMode.SIMPLE)) .then("Advanced >>").otherwise("<< Simple")); CategoryTabTreeView.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> { if (newValue != null) { TreeItem<String> scriptValue = TreeUtils.getRootMinusOne((TreeItem<String>) newValue); TreeItem<String> selectedValue = (TreeItem<String>) newValue; CategoryTabScriptValueLabel.setText(scriptValue.getValue()); selectedScriptNodeIsLeaf.set(selectedValue.isLeaf()); } }); }