@FXML
private void initialize() {
// 0. Initialize the columns.
idColumn.setCellValueFactory(cellData -> cellData.getValue().idProperty());
nameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
uuidColumn.setCellValueFactory(cellData -> cellData.getValue().uuidProperty());
txpowerColumn.setCellValueFactory(cellData -> cellData.getValue().txpowerProperty());
minorIDColumn.setCellValueFactory(cellData -> cellData.getValue().minorIDProperty());
majorIDColumn.setCellValueFactory(cellData -> cellData.getValue().majorIDProperty());
// 1. Wrap the ObservableList in a FilteredList (initially display all data).
FilteredList<ConfigModel> filteredData = new FilteredList<>(configModels, p -> true);
// 2. Set the filter Predicate whenever the filter changes.
filterField.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate(beacon -> {
// If filter text is empty, display all persons.
if (newValue == null || newValue.isEmpty()) {
return true;
}
String lowerCaseFilter = newValue.toLowerCase();
if (beacon.getName().toLowerCase().contains(lowerCaseFilter)) {
return true;
} else if (beacon.minorIDMatches(lowerCaseFilter)) {
return true;
} else if (beacon.idMatches(lowerCaseFilter)) {
return true;
}
return false;
});
});
// 3. Wrap the FilteredList in a SortedList.
SortedList<ConfigModel> sortedData = new SortedList<>(filteredData);
// 4. Bind the SortedList comparator to the TableView comparator.
sortedData.comparatorProperty().bind(configsTable.comparatorProperty());
// 5. Add sorted (and filtered) data to the table.
configsTable.setItems(sortedData);
}
BeaconConfigsViewController.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:RaspberryPiBeaconParser
作者:
评论列表
文章目录