本文整理汇总了Java中javafx.collections.transformation.FilteredList类的典型用法代码示例。如果您正苦于以下问题:Java FilteredList类的具体用法?Java FilteredList怎么用?Java FilteredList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FilteredList类属于javafx.collections.transformation包,在下文中一共展示了FilteredList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addListeners
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
/**
* Adds event listeners to update the list of genomes when the user selects a specific genome.
* <p>
* Will update the
*/
void addListeners() {
final FilteredList<GenomePath> filteredList = new FilteredList<>(graphVisualizer.getGenomePathsProperty(),
s -> s.getName().contains(searchField.textProperty().get()));
pathTable.setItems(filteredList);
// Updates the filtered list predicate on a search
searchField.textProperty().addListener((observable, oldValue, newValue) ->
filteredList.setPredicate(getPredicate(newValue)));
matchCase.selectedProperty().addListener((observable, oldValue, newValue) ->
filteredList.setPredicate(getPredicate(searchField.getText())));
regex.selectedProperty().addListener((observable, oldValue, newValue) ->
filteredList.setPredicate(getPredicate(searchField.getText())));
// Updates the label with the number of paths that are displayed
filteredList.getSource().addListener((ListChangeListener<GenomePath>) c ->
pathsFound.textProperty().setValue("Paths found: " + filteredList.size()));
}
示例2: CollatedTreeItem
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
public CollatedTreeItem() {
children = FXCollections.observableArrayList();
filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
@Override public boolean test(TreeItem<T> t) {
return filter.test(t.getValue());
}
});
sortedChildren = new SortedList<>(filteredChildren);
ObservableList<TreeItem<T>> original = super.getChildren();
sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
@Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
while (c.next()) {
original.removeAll(c.getRemoved());
original.addAll(c.getFrom(), c.getAddedSubList());
}
}
});
}
示例3: FilterableTreeItem
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
public FilterableTreeItem(T value) {
super(value);
this.sourceList = FXCollections.observableArrayList();
this.filteredList = new FilteredList<>(this.sourceList);
this.filteredList.predicateProperty().bind(Bindings.createObjectBinding(() -> {
return child -> {
// Set the predicate of child items to force filtering
if (child instanceof FilterableTreeItem) {
FilterableTreeItem<T> filterableChild = (FilterableTreeItem<T>) child;
filterableChild.setPredicate(this.predicate.get());
}
// If there is no predicate, keep this tree item
if (this.predicate.get() == null)
return true;
// If there are children, keep this tree item
if (child.getChildren().size() > 0)
return true;
// Otherwise ask the TreeItemPredicate
return this.predicate.get().test(this, child.getValue());
};
}, this.predicate));
setHiddenFieldChildren(this.filteredList);
}
示例4: FilterableTreeItem
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
public FilterableTreeItem(T value) {
super(value);
FilteredList<TreeItem<T>> filteredChildren = new FilteredList<>(sourceChildren);
filteredChildren.predicateProperty().bind(Bindings.createObjectBinding(() -> {
Predicate<TreeItem<T>> p = child -> {
if (child instanceof FilterableTreeItem) {
((FilterableTreeItem<T>) child).predicateProperty().set(predicate.get());
}
if (predicate.get() == null || !child.getChildren().isEmpty()) {
return true;
}
return predicate.get().test(this, child.getValue());
};
return p;
}, predicate));
setHiddenFieldChildren(filteredChildren);
}
示例5: initialize
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
public void initialize() {
venues.setOnShowing(event -> {
AppBar appBar = getApp().getAppBar();
appBar.setNavIcon(getApp().getNavMenuButton());
appBar.setTitleText(OTNView.VENUES.getTitle());
appBar.getActionItems().add(getApp().getSearchButton());
venuesListView.setSelectedItem(null);
});
venuesListView.getStyleClass().add("venues-list-view");
venuesListView.setPlaceholder(new Placeholder(PLACEHOLDER_MESSAGE, OTNView.VENUES.getMenuIcon()));
filteredVenues = new FilteredList<>(service.retrieveVenues());
venuesListView.setItems(filteredVenues);
venuesListView.setCellFactory(p -> new VenueCell());
// venuesListView.selectedItemProperty().addListener((observable, oldValue, newValue) -> {
// if (newValue != null) {
// OTNView.VENUE.switchView().ifPresent( presenter ->
// ((VenuePresenter)presenter).setVenue(newValue));
// }
// });
}
示例6: setupSorting
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
private void setupSorting() {
FilteredList<Item> filteredData = new FilteredList<>(itemList, p -> true);
filterField.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate(item -> {
if(newValue == null || newValue.isEmpty() )
return true;
if(item.getName().toLowerCase().contains(newValue.toLowerCase())){
return true;
} else {
return false;
}
});
});
SortedList<Item> sortedData = new SortedList<>(filteredData);
sortedData.comparatorProperty().bind(itemTable.comparatorProperty());
itemTable.setItems(sortedData);
}
示例7: change
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
private void change (SessionTable table, FilteredList<SessionRecord> filteredData)
{
// get the previously selected line
SessionRecord selectedRecord = table.getSelectionModel ().getSelectedItem ();
// change the filter predicate
filteredData.setPredicate (sessionRecord -> sessionRecord.isTN3270 ()
|| (sessionRecord.isTelnet () && showTelnetCB.isSelected ())
|| (sessionRecord.isTN3270Extended () && show3270ECB.isSelected ()));
// restore the previously selected item (if it is still visible)
if (selectedRecord != null)
{
table.getSelectionModel ().select (selectedRecord);
table.requestFocus ();
}
}
示例8: setFilter
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
private void setFilter (FilteredList<ConsoleMessage> filteredData)
{
String time = txtTime.getText ();
String task = txtTask.getText ();
String code = txtMessageCode.getText ();
String text = txtMessageText.getText ();
filteredData.setPredicate (message ->
{
boolean p0 = message.getTime ().startsWith (time);
boolean p1 = message.getTask ().startsWith (task);
boolean p2 = message.getMessageCode ().startsWith (code);
boolean p3 = message.getMessage ().contains (text);
return p0 && p1 && p2 && p3;
});
}
示例9: constructStatisticRepresentation
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
/**
* Method to recalculate the statistic value.
* @param relevantJobs the {@link FilteredList} of {@link JenkinsJob}s to use in the statistic.
* @return the {@link String} representation of the statistic.
*/
@Override protected String constructStatisticRepresentation( FilteredList< JenkinsJob > relevantJobs ){
int recalculatedTotal = 0;
int recalculatedCount = 0;
for ( JenkinsJob j : relevantJobs ) {
recalculatedCount += ( j.testTotalCount().get() - j.testFailureCount().get() );
recalculatedTotal += j.testTotalCount().get();
}
if ( recalculatedCount == passing && recalculatedTotal == total ) {
return null;
}
this.passing = recalculatedCount;
this.total = recalculatedTotal;
return recalculatedCount + "/" + recalculatedTotal;
}
示例10: constructStatisticRepresentation
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
/**
* Method to recalculate the statistic value.
* @param relevantJobs the {@link FilteredList} of {@link JenkinsJob}s to use in the statistic.
* @return the {@link String} representation of the statistic.
*/
@Override protected String constructStatisticRepresentation( FilteredList< JenkinsJob > relevantJobs ){
Long recalculatedTimestamp = null;
for ( JenkinsJob j : relevantJobs ) {
Long timestamp = j.buildTimestampProperty().get();
if ( timestamp == null ) {
continue;
}
if ( recalculatedTimestamp == null ) {
recalculatedTimestamp = timestamp;
continue;
}
if ( recalculatedTimestamp < timestamp ) {
recalculatedTimestamp = j.buildTimestampProperty().get();
}
}
if ( recalculatedTimestamp == null ) {
return UNKNOWN;
}
return timestampformatter.format( recalculatedTimestamp, DATE_TIME_FORMATTER );
}
示例11: constructStatisticRepresentation
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
/**
* Method to recalculate the statistic value.
* @param relevantJobs the {@link FilteredList} of {@link JenkinsJob}s to use in the statistic.
* @return the {@link String} representation of the statistic.
*/
@Override protected String constructStatisticRepresentation( FilteredList< JenkinsJob > relevantJobs ){
Set< JenkinsNode > nodesInUse = new HashSet<>();
for ( JenkinsJob j : relevantJobs ) {
if ( j.buildStateProperty().get() == BuildState.Built ) {
continue;
}
JenkinsNode node = j.builtOnProperty().get();
if ( node == null ) {
continue;
}
nodesInUse.add( node );
}
int recalculatedCount = nodesInUse.size();
if ( recalculatedCount == this.count ) {
return null;
}
this.count = recalculatedCount;
return Integer.toString( recalculatedCount );
}
示例12: FilterableTreeItem
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
public FilterableTreeItem(T value) {
super(value);
sourceList = FXCollections.observableArrayList();
filteredList = new FilteredList<>(sourceList);
filteredList.predicateProperty().bind(Bindings.createObjectBinding(() -> {
return child -> {
// Set the predicate of child items to force filtering
if (child instanceof FilterableTreeItem) {
FilterableTreeItem<T> filterableChild = (FilterableTreeItem<T>) child;
filterableChild.setPredicate(predicate.get());
}
// If there is no predicate, keep this tree item
if (predicate.get() == null)
return true;
// If there are children, keep this tree item
if (child.getChildren().size() > 0)
return true;
// Otherwise ask the TreeItemPredicate
return predicate.get().test(this, child.getValue());
};
}, predicate));
setHiddenFieldChildren(filteredList);
}
示例13: createFilterTab
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
private Node createFilterTab() {
GridPane pane = new GridPane();
pane.setHgap(10d);
pane.setVgap(10d);
leageList = new FilteredList<String>(model.getLeages(), value -> true);
leageFilter = new ComboBox<String>(leageList);
// leageFilter.valueProperty().addListener(value -> update());
from = new NumberField();
to = new NumberField();
teamEloTable.fromProperty().bindBidirectional(from.integerProperty());
teamEloTable.toProperty().bindBidirectional(to.integerProperty());
pane.add(leageFilter, 1, 1);
pane.addRow(2, from, to);
return pane;
}
示例14: loadStudents
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
private void loadStudents() {
try {
String query = "SELECT * FROM student";
System.out.println("Query [" + query + "]");
ResultSet result = statement.executeQuery(query);
students = FXCollections.observableArrayList();
filteredStudents = new FilteredList(students, p -> true);
studentListView.setItems(filteredStudents);
while (result.next()) {
Student student = new Student(result.getString("id"),
result.getString("name"),
result.getString("sex").charAt(0) == 'M' ? Sex.MALE : Sex.FEMALE,
result.getDate("dob").toLocalDate());
students.add(student);
}
} catch (SQLException ex) {
Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例15: toggleVisibility
import javafx.collections.transformation.FilteredList; //导入依赖的package包/类
private void toggleVisibility(RowConstraints row,
FilteredList<Node> children,
boolean show) {
if (show) {
row.setMaxHeight(USE_COMPUTED_SIZE);
row.setMinHeight(10);
} else {
row.setMaxHeight(0);
row.setMinHeight(0);
}
children.forEach(n -> {
n.setVisible(show);
n.setManaged(show);
});
}