Skip to content

Commit

Permalink
update on search
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed May 25, 2019
1 parent 858ffd8 commit 6db6073
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public MainTableDataModel(BibDatabaseContext context) {
Globals.stateManager.searchResultSizeProperty().bind(Bindings.size(entriesFiltered));
// We need to wrap the list since otherwise sorting in the table does not work
entriesSorted = new SortedList<>(entriesFiltered);

}

private boolean isMatched(BibEntryTableViewModel entry) {
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ public GlobalSearchBar(JabRefFrame frame) {
this.setAlignment(Pos.CENTER_LEFT);

//TODO Needs fixing, not yet working correctly
EasyBind.subscribe(Globals.stateManager.searchResultSizeProperty(), matchedResults -> {

Globals.stateManager.activeSearchQueryProperty().getValue().ifPresent(searchQuery -> {
updateResults(matchedResults.intValue(), SearchDescribers.getSearchDescriberFor(searchQuery).getDescription(),
searchQuery.isGrammarBasedSearch());
EasyBind.subscribe(Globals.stateManager.activeSearchQueryProperty(), searchQuery -> {
searchQuery.ifPresent(query -> {
updateResults(Globals.stateManager.searchResultSizeProperty().intValue(), SearchDescribers.getSearchDescriberFor(query).getDescription(),
query.isGrammarBasedSearch());
});

});

}

private void toggleSearchModeAndSearch() {
Expand Down Expand Up @@ -271,6 +272,8 @@ private SearchQuery getSearchQuery() {
}

public void updateResults(int matched, TextFlow description, boolean grammarBasedSearch) {
System.out.println("matched" + matched);

if (matched == 0) {
currentResults.setText(Localization.lang("No results found."));
searchField.pseudoClassStateChanged(CLASS_NO_RESULTS, true);
Expand Down

0 comments on commit 6db6073

Please sign in to comment.