Repository navigation
Restore full-text results in the entry editor #17367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ | |
| import javafx.beans.property.IntegerProperty; | ||
| import javafx.beans.property.ListProperty; | ||
| import javafx.beans.property.ObjectProperty; | ||
| import javafx.beans.property.ReadOnlyObjectProperty; | ||
| import javafx.beans.property.ReadOnlyObjectWrapper; | ||
| import javafx.beans.property.SimpleObjectProperty; | ||
| import javafx.collections.ObservableList; | ||
| import javafx.collections.transformation.FilteredList; | ||
|
|
@@ -22,6 +24,7 @@ | |
| import org.jabref.gui.search.MatchCategory; | ||
| import org.jabref.gui.util.BindingsHelper; | ||
| import org.jabref.gui.util.FilteredListProxy; | ||
| import org.jabref.gui.util.UiTaskExecutor; | ||
| import org.jabref.logic.search.SearchContext; | ||
| import org.jabref.logic.search.SearchPreferences; | ||
| import org.jabref.logic.util.BackgroundTask; | ||
|
|
@@ -55,6 +58,7 @@ public class MainTableDataModel { | |
| private final FilteredList<BibEntryTableViewModel> entriesFiltered; | ||
| private final SortedList<BibEntryTableViewModel> entriesFilteredAndSorted; | ||
| private final ObjectProperty<MainTableFieldValueFormatter> fieldValueFormatter = new SimpleObjectProperty<>(); | ||
| private final ReadOnlyObjectWrapper<Optional<SearchResults>> searchResults = new ReadOnlyObjectWrapper<>(Optional.empty()); | ||
| private final GroupsPreferences groupsPreferences; | ||
| private final SearchPreferences searchPreferences; | ||
| private final NameDisplayPreferences nameDisplayPreferences; | ||
|
|
@@ -108,6 +112,11 @@ public MainTableDataModel(BibDatabaseContext context, | |
|
|
||
| private void updateSearchMatches(Optional<SearchQuery> query) { | ||
| long updateSequence = searchUpdateSequence.incrementAndGet(); | ||
| UiTaskExecutor.runNowOrInJavaFXThread(() -> { | ||
| if (updateSequence == searchUpdateSequence.get()) { | ||
| searchResults.set(Optional.empty()); | ||
| } | ||
| }); | ||
| Optional<SearchQuery> querySnapshot = query.map(searchQuery -> new SearchQuery( | ||
| searchQuery.getSearchExpression(), | ||
| EnumSet.copyOf(searchQuery.getSearchFlags()))); | ||
|
|
@@ -118,14 +127,16 @@ private void updateSearchMatches(Optional<SearchQuery> query) { | |
| if (updateSequence != searchUpdateSequence.get()) { | ||
| return; | ||
| } | ||
| results.ifPresentOrElse( | ||
| this::setSearchMatches, | ||
| this::clearSearchMatches | ||
| ); | ||
| searchResults.set(results); | ||
| results.ifPresentOrElse(this::setSearchMatches, this::clearSearchMatches); | ||
|
Comment on lines
+133
to
+134
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange that both ( Should we creae/link requirements on the various places?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a comment and requirements |
||
| FilteredListProxy.refilterListReflection(entriesFiltered); | ||
| }).executeWith(taskExecutor); | ||
| } | ||
|
|
||
| public ReadOnlyObjectProperty<Optional<SearchResults>> searchResultsProperty() { | ||
| return searchResults.getReadOnlyProperty(); | ||
| } | ||
|
|
||
| /// Refresh the current search | ||
| /// | ||
| /// We need to call this when the database is switched during a fulltext search since | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please a small Java comment on the why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comment