Skip to content
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

Feature: implement search filter in show preferences #4759

Merged
merged 8 commits into from
Mar 15, 2019
Merged

Feature: implement search filter in show preferences #4759

merged 8 commits into from
Mar 15, 2019

Conversation

CaptainDaVinci
Copy link
Contributor

@CaptainDaVinci CaptainDaVinci commented Mar 13, 2019

Add a search box in show preferences window to allow users to filter
preference options.

Resolves #1019

preferences


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

Add a search box in show preferences window to allow users to filter
preference options.

Resolves #1019
}

List<JabRefPreferencesFilter.PreferenceOption> filteredOptions = auxillaryPreferenceOptions.stream()
.filter(p -> p.getKey().toLowerCase().contains(searchText))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use LOCALE.ROOT as second parameter for the toLowerCase function to avoid unexpected problems:
https://garygregory.wordpress.com/2015/11/03/java-lowercase-conversion-turkey/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, I have made the necessary changes.

@Siedlerchr
Copy link
Member

Codewise lgtm. Could you please provide a screenshot how it looks like when the search matched/text is found?

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. The code looks good and works, but can still be a bit improved using a FilteredList (which encapsulates some of the things you had to implement your own).

@@ -22,6 +23,12 @@
<Label fx:id="count"/>
</HBox>
</bottom>
<top>
<HBox>
<TextField fx:id="searchField" promptText="Search"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use %Search so that the text get localized properly.

@@ -22,6 +26,7 @@

private final JabRefPreferencesFilter preferencesFilter;
private final ObservableList<JabRefPreferencesFilter.PreferenceOption> preferenceOptions;
private final List<JabRefPreferencesFilter.PreferenceOption> auxillaryPreferenceOptions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use the FilteredList, then the code gets somewhat cleaner (as you don't need to manage two lists on your own). Have a look here:

entriesFiltered = new FilteredList<>(entriesViewModel);
entriesFiltered.predicateProperty().bind(
Bindings.createObjectBinding(() -> this::isMatched,
Globals.stateManager.activeGroupProperty(), Globals.stateManager.activeSearchQueryProperty())
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestions! I have made the necessary changes.

@CaptainDaVinci
Copy link
Contributor Author

@Siedlerchr I have added a screenshot now.

@CaptainDaVinci
Copy link
Contributor Author

CaptainDaVinci commented Mar 14, 2019

  1. Will moving the checkbox next to the search field provide a better UX?
  2. Should the count label be bound to filteredOptions.size()?

@Siedlerchr
Copy link
Member

Yeah! That's cool, looks good, I would move the checkbox to the top next to the search field.
Regarding your second option: Either you directly bind it to the filtered list size property or you update the text in the method which is your current way. But both together will result in an error: A bound value cannot be set ;)
So as you automatically call the updateModel method on changes, you can leave it as is.

@CaptainDaVinci
Copy link
Contributor Author

But the updatedModel() is called only when check box is changed, I was wondering if having it update while filtering would be a good addition.

@CaptainDaVinci
Copy link
Contributor Author

CaptainDaVinci commented Mar 15, 2019

On moving the checkbox to the top next to the search field, what are your opinion on it @tobiasdiez @Siedlerchr ?
2019-03-15-181809_1920x1080_scrot

@Siedlerchr
Copy link
Member

Yep, that is exactly what I meant'! Looks good! And thanks for fixing this longstanding issue ;)

@CaptainDaVinci
Copy link
Contributor Author

CaptainDaVinci commented Mar 15, 2019

I am glad it came out as expected! :)
However, I think that the count label should be bound to the table size, so that the right count is shown when filtering. I will push the changes and we can decide on whether to merge the change or stick with the current setup.

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The code looks good and I like the idea of having the count bound to the actual number of entries displayed.

@tobiasdiez tobiasdiez merged commit cd979c5 into JabRef:master Mar 15, 2019
Siedlerchr added a commit that referenced this pull request Mar 16, 2019
…erbibtexkey

* upstream/master: (827 commits)
  [#4306] Disable renaming (#4727)
  Feature: implement search filter in show preferences (#4759)
  Enable import button only if entry selected (#4761)
  Improve Remote messaging (#4760)
  Add changelog entry for #4520
  Modifications to improve contrast of UI elements (#4758)
  Rework external changes dialog in JavaFX (#4693)
  Changes the title of Group Dialog to Add subgroup when adding a new subgroup (#4757)
  Optimize data fetching (#4520)
  Adds a browse button next to the path text field for aux-based groups (#4743)
  Saving changes and exiting application (#4729)
  Code optimized and created a reusable method to get writer output (#4750)
  Bump mvvmfx from 1.7.0 to 1.8.0 (#4747)
  Bump guava from 27.0.1-jre to 27.1-jre (#4748)
  Bump mvvmfx-validation from 1.7.0 to 1.8.0 (#4749)
  Remove obsolete swing components in Preferences and OpenOffice (#4740)
  Move library specific key pattern dialog call to library menu (#4744)
  Revert "Revert "Fix: bibkey generated does not handle diacritics" (#4741)" (#4742)
  Revert "Fix: bibkey generated does not handle diacritics" (#4741)
  Rename method to removeUnwantedCharacters
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants