Java Code Examples for javafx.collections.transformation.FilteredList#setPredicate()

The following examples show how to use javafx.collections.transformation.FilteredList#setPredicate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LibraryController.java    From houdoku with MIT License 7 votes vote down vote up
/**
 * Set the predicate of the series table's FilteredList.
 * 
 * <p>This method filters the given list based on the contents of the filterTextField and on the
 * selected category.
 * 
 * <p>This method needs to be called whenever actions which could change the predicate are
 * performed - i.e., clicking a category.
 *
 * @param filteredData the FilteredList of series to set the predicate of
 */
private void setCombinedPredicate(FilteredList<Series> filteredData) {
    filteredData.setPredicate(series -> {
        // check that the series title, author, or artist contains the
        // text filter
        String filter = filterTextField.getText().toLowerCase();
        boolean title_matches = series.getTitle().toLowerCase().contains(filter);
        boolean creator_matches = (series.author != null
                && series.author.toLowerCase().contains(filter))
                || (series.artist != null && series.artist.toLowerCase().contains(filter));

        // check that the series has the selected category
        boolean category_matches = false;
        if (treeView.getSelectionModel().getSelectedItem() != null) {
            TreeItem<Category> selectedTreeCell =
                    treeView.getSelectionModel().getSelectedItem();
            Category category = selectedTreeCell.getValue();
            category_matches = series.getStringCategories().stream()
                    .anyMatch(stringCategory -> stringCategory.equals(category.getName()))
                    || category.equals(library.getRootCategory());
        }

        return (title_matches || creator_matches) && category_matches;
    });
}
 
Example 2
Source File: ReplayStage.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
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 ();
  }
}
 
Example 3
Source File: ConsoleMessageTab.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
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;
  });
}
 
Example 4
Source File: ReplayStage.java    From dm3270 with Apache License 2.0 6 votes vote down vote up
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 ();
  }
}
 
Example 5
Source File: ConsoleMessageTab.java    From dm3270 with Apache License 2.0 6 votes vote down vote up
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;
  });
}
 
Example 6
Source File: DbgView.java    From erlyberly with GNU General Public License v3.0 6 votes vote down vote up
private void filterForFunctionTextMatch(String search) {
    String[] split = search.split(":");

    if(split.length == 0)
        return;

    final String moduleName = split[0];
    final String funcName = (split.length > 1) ? split[1] : "";

    if(search.contains(":")) {
        for (TreeItem<ModFunc> treeItem : filteredTreeModules) {
            treeItem.setExpanded(true);
        }
    }

    for (FilteredList<TreeItem<ModFunc>> funcItemList : functionLists.values()) {
        funcItemList.setPredicate((t) -> { return isMatchingModFunc(funcName, t); });
    }

    filteredTreeModules.setPredicate((t) -> { return isMatchingModFunc(moduleName, t) && !t.getChildren().isEmpty(); });
}
 
Example 7
Source File: PersonsController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
protected void doFilterTable(TextField tf) {
	String criteria = tf.getText();
	
	if( logger.isLoggable(Level.FINE) ) {
		logger.fine( "[FILTER] filtering on=" + criteria );
	}
	
	if( criteria == null || criteria.isEmpty() ) {
		tblPersons.setItems( personsActiveRecord );
		return;
	}
	
	FilteredList<Person> fl = new FilteredList<>(personsActiveRecord, p -> true);
	
	fl.setPredicate(person -> {

		if (criteria == null || criteria.isEmpty()) {
             return true;
         }

         String lcCriteria = criteria.toLowerCase();

         if (person.getFirstName().toLowerCase().contains(lcCriteria)) {
             return true; // Filter matches first name.
         } else if (person.getLastName().toLowerCase().contains(lcCriteria)) {
             return true; // Filter matches last name.
         } else if (person.getEmail().toLowerCase().contains(lcCriteria)) {
        	 return true;  // 	matches email
         }
         
         return false; // Does not match.
     });
	
	 SortedList<Person> sortedData = new SortedList<>(fl);
	 sortedData.comparatorProperty().bind(tblPersons.comparatorProperty());  // ?    	
	 tblPersons.setItems(sortedData);
}
 
Example 8
Source File: DbgView.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
private void filterForTracedFunctions() {
    for (FilteredList<TreeItem<ModFunc>> funcItemList : functionLists.values()) {
        funcItemList.setPredicate((t) -> { return dbgController.isTraced(t.getValue()); });
    }

    filteredTreeModules.setPredicate((t) -> { return !t.getChildren().isEmpty(); });
}