// Handler for MenuItem[fx:id="assignOfficialMenuItem"] onAction public void assignOfficial(ActionEvent event) { // TODO add assertions to be sure that no null value are passed to the // controller officialsController.assignOfficialTo( officialsFilteredTableView.getSelectionModel().getSelectedItem(), assigmentsListView.getSelectionModel().getSelectedItem()); }
private void initializeAssignmentListViewAndFilters() { final ListBinding<PersonnelAssignment> filteredAssignementBinding = new ListBinding<PersonnelAssignment>() { final ObjectBinding<ObservableList<PersonnelAssignment>> internalBinding = Bindings.select( assignmentsFilterComboBox.getSelectionModel().selectedItemProperty(), "assignments"); { bind(internalBinding); } @Override protected ObservableList<PersonnelAssignment> computeValue() { return internalBinding.get(); } @Override public Spliterator<PersonnelAssignment> spliterator() { return super.spliterator(); } }; assigmentsListView.itemsProperty().bind(filteredAssignementBinding); assigmentsListView.setCellFactory( new PropertyListCellFactory<PersonnelAssignment>("name", null)); assignmentsFilterComboBox.getItems().clear(); assignmentsFilterComboBox.getItems().addAll(assignementFilters); assignmentsFilterComboBox.setCellFactory( new PropertyListCellFactory<AssignementFilter>("name", null)); assignmentsFilterComboBox.setButtonCell( new ListCell<AssignementFilter>() { @Override protected void updateItem(AssignementFilter item, boolean empty) { super.updateItem(item, empty); if (textProperty().isBound()) { textProperty().unbind(); } if (item != null || !empty) { textProperty().bind(item.nameProperty()); } } }); }