List of usage examples for javafx.beans.binding BooleanBinding BooleanBinding
public BooleanBinding()
From source file:gov.va.isaac.gui.listview.operations.ParentRetire.java
@Override public void init(ObservableList<SimpleDisplayConcept> conceptList) { super.init(conceptList); root_.add(new Label("Retire as parent"), 0, 0); retireAsParent_.setPromptText("-Populate the Concepts List-"); Node n = ErrorMarkerUtils.setupErrorMarker(retireAsParent_, replaceOptionsInvalidString_); root_.add(n, 1, 0);//from w w w .j a va 2 s .co m ComboBoxSetupTool.setupComboBox(retireAsParent_); // TODO populate retireAsParentCombo retireAsParent_.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(n, Priority.ALWAYS); FxUtils.preventColCollapse(root_, 0); retireAsParent_.getItems().addListener(new ListChangeListener<SimpleDisplayConcept>() { @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends SimpleDisplayConcept> c) { if (retireAsParent_.getItems().size() > 0) { replaceOptionsInvalidString_.set(null); if (retireAsParent_.getSelectionModel().getSelectedItem() == null) { retireAsParent_.getSelectionModel().selectFirst(); } } else { replaceOptionsInvalidString_.set("A concept must be selected from this drop down"); retireAsParent_.getSelectionModel().clearSelection(); retireAsParent_.setValue(null); retireAsParent_.setPromptText("-Populate the Concepts List-"); } } }); allValid_ = new BooleanBinding() { { super.bind(replaceOptionsInvalidString_); } @Override protected boolean computeValue() { return StringUtils.isBlank(replaceOptionsInvalidString_.get()); } }; }
From source file:gov.va.isaac.gui.listview.operations.ParentReplace.java
private void initActionListeners() { replaceOptions_.getItems().addListener(new ListChangeListener<SimpleDisplayConcept>() { @Override/*from www. j a v a 2 s . c o m*/ public void onChanged(ListChangeListener.Change<? extends SimpleDisplayConcept> c) { if (replaceOptions_.getItems().size() > 0) { replaceOptionsInvalidString_.set(null); if (replaceOptions_.getSelectionModel().getSelectedItem() == null) { replaceOptions_.getSelectionModel().selectFirst(); } } else { replaceOptionsInvalidString_.set("A concept must be selected from this drop down"); replaceOptions_.getSelectionModel().clearSelection(); replaceOptions_.setValue(null); replaceOptions_.setPromptText("-Populate the Concepts List-"); } } }); operationIsReady_ = new BooleanBinding() { { super.bind(replaceOptionsInvalidString_, withConcept_.isValid()); } @Override protected boolean computeValue() { if (StringUtils.isBlank(replaceOptionsInvalidString_.get()) && withConcept_.isValid().get()) { return true; } return false; } }; }
From source file:com.rvantwisk.cnctools.controls.ToolParametersControl.java
@FXML void initialize() { assert iDiameter != null : "fx:id=\"iDiameter\" was not injected: check your FXML file 'ToolParameters.fxml'."; assert iName != null : "fx:id=\"iName\" was not injected: check your FXML file 'ToolParameters.fxml'."; final InputMaskChecker listener1 = new InputMaskChecker(InputMaskChecker.NOTEMPTY, iName); // final InputMaskChecker listener2 = new InputMaskChecker(InputMaskChecker.NOTEMPTY, iDiameter); iName.textProperty().addListener(listener1); //iDiameter.textProperty().addListener(listener2); cbToolType.setItems(tools);/*from w ww . ja v a 2s. c om*/ final BooleanBinding binding = new BooleanBinding() { { // super.bind(listener1.erroneous, listener2.erroneous); } @Override protected boolean computeValue() { return true; // (listener1.erroneous.get() || listener2.erroneous.get()); } }; binding.invalidate(); }
From source file:com.panemu.tiwulfx.table.TableControl.java
public TableControl(Class<R> recordClass) { this.recordClass = recordClass; initControls();// www. j a v a2s . c om tblView.getSortOrder().addListener(new ListChangeListener<TableColumn<R, ?>>() { @Override public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) { reload(); } }); btnAdd.disableProperty().bind(mode.isEqualTo(Mode.EDIT)); btnEdit.disableProperty().bind(mode.isNotEqualTo(Mode.READ)); btnSave.disableProperty().bind(mode.isEqualTo(Mode.READ)); btnDelete.disableProperty().bind(new BooleanBinding() { { super.bind(mode, tblView.getSelectionModel().selectedItemProperty(), lstChangedRow); } @Override protected boolean computeValue() { if ((mode.get() == Mode.INSERT && lstChangedRow.size() < 2) || tblView.getSelectionModel().selectedItemProperty().get() == null || mode.get() == Mode.EDIT) { return true; } return false; } }); tblView.editableProperty().bind(mode.isNotEqualTo(Mode.READ)); tblView.getSelectionModel().cellSelectionEnabledProperty().bind(tblView.editableProperty()); mode.addListener(new ChangeListener<Mode>() { @Override public void changed(ObservableValue<? extends Mode> ov, Mode t, Mode t1) { if (t1 == Mode.READ) { directEdit = false; } } }); tblView.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { lblRowIndex .setText(TiwulFXUtil.getLiteral("row.param", (page * maxResult.get() + t1.intValue() + 1))); } }); tblView.getFocusModel().focusedCellProperty().addListener(new ChangeListener<TablePosition>() { @Override public void changed(ObservableValue<? extends TablePosition> observable, TablePosition oldValue, TablePosition newValue) { if (tblView.isEditable() && directEdit && agileEditing.get()) { tblView.edit(newValue.getRow(), newValue.getTableColumn()); } } }); tblView.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ESCAPE) { directEdit = false; } else if (event.getCode() == KeyCode.ENTER && mode.get() == Mode.READ) { getController().doubleClick(getSelectionModel().getSelectedItem()); } } }); /** * Define policy for TAB key press */ tblView.addEventFilter(KeyEvent.KEY_PRESSED, tableKeyListener); /** * In INSERT mode, only inserted row that is focusable */ tblView.getFocusModel().focusedCellProperty().addListener(tableFocusListener); tblView.setOnMouseReleased(tableRightClickListener); if (Platform.isFxApplicationThread()) { cm = new ContextMenu(); cm.setAutoHide(true); setToolTips(); /** * create custom row factory that can intercept double click on grid row */ tblView.setRowFactory(new Callback<TableView<R>, TableRow<R>>() { @Override public TableRow<R> call(TableView<R> param) { return new TableRowControl(TableControl.this); } }); } columns.addListener(new ListChangeListener<TableColumn<R, ?>>() { @Override public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) { while (change.next()) { if (change.wasAdded()) { for (TableColumn<R, ?> column : change.getAddedSubList()) { initColumn(column); } } lastColumnIndex = getLeafColumns().size() - 1; } } }); attachWindowVisibilityListener(); }