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

Fix context menu of the search bar #11446

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

LoayGhreeb
Copy link
Collaborator

@LoayGhreeb LoayGhreeb commented Jul 1, 2024

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@koppor
Copy link
Member

koppor commented Jul 1, 2024

Human testing for tab (library) switching:

  1. Open two libraries A and B
  2. Search in library A using query q1
  3. Switch to library B
  4. Search results should match q1 (and not no query)

@Siedlerchr
Copy link
Member

Test with the different modes, global search and search across libraries

Comment on lines -211 to -218
regexValidator = new FunctionBasedValidator<>(
searchField.textProperty(),
query -> !(regularExpressionButton.isSelected() && !validRegex()),
ValidationMessage.error(Localization.lang("Invalid regular expression")));
ControlsFxVisualizer visualizer = new ControlsFxVisualizer();
visualizer.setDecoration(new IconValidationDecorator(Pos.CENTER_LEFT));
Platform.runLater(() -> visualizer.initVisualization(regexValidator.getValidationStatus(), searchField));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've removed this validator because it is not listening for changes of the modifier buttons, an exception will be thrown in this case: write an invalid regex in the search bar, with the regex modifier disabled, then enable the regex button. will throw java.util.regex.PatternSyntaxException: Unclosed group near index 4 (k\)

Also, this visualizer throws an exception in the global search window. (Open the window, enable regex modifier, write an invalid query, close the window, and open it again will throw java.lang.IllegalArgumentException: DialogPane@30d0220[styleClass=dialog-pane]is already inside a scene-graph and cannot be set as root.

Copy link
Member

@HoussemNasri HoussemNasri Jul 9, 2024

Choose a reason for hiding this comment

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

Have you tried EasyBind#combine to combine listening for searchField text property and change of selection of the modifier button? Overall, I think we should stick to one pattern to display errors to users, unless it is necessary to implement a workaround.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, using EasyBind#combine works, but for the second issue, the global search window will not open again if it was closed with the visualizer.

However, we already show a message indicating that the query is invalid.
image

With the visualizer, we only add an icon before the search bar.
image

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I see. If it's necessary then let's keep it.

@LoayGhreeb
Copy link
Collaborator Author

org.jabref.gui.preview.PreviewViewer needs to be refactored to register the listener for the library's search query instead of the StateManager. This will be done in a follow-up PR.

if (!registered) {
stateManager.activeSearchQueryProperty().addListener(listener);
stateManager.activeGlobalSearchQueryProperty().addListener(listener);
registered = true;
}
highlightSearchPattern();

This class is used in multiple locations, most of which don't have access to the LibraryTab to retrieve the SearchQueryProperty (maybe most of the PreviewViewer instances don't need to highlight the search pattern. Highlighting is needed only in the entry editor and the global search window).

@LoayGhreeb LoayGhreeb marked this pull request as draft July 3, 2024 20:26
@calixtus
Copy link
Member

calixtus commented Jul 4, 2024

I noticed you make several changes and fixes to the ui. Please don't forget to create screenshots before and after the change.

@koppor koppor added this to the 6.0-alpha milestone Jul 4, 2024
@LoayGhreeb LoayGhreeb changed the title Performance improvement to search/selecting groups when opening multiple libraries Fix context menu of the search bar Jul 8, 2024
@LoayGhreeb LoayGhreeb marked this pull request as ready for review July 8, 2024 19:21
@HoussemNasri
Copy link
Member

Although the ctrl+shift+F shortcut does work, I couldn't find it in preferences:

image

@LoayGhreeb
Copy link
Collaborator Author

Although the ctrl+shift+F shortcut does work, I couldn't find it in preferences:

I can see it on my machine, but that might be because I cleared the preferences after adding the shortcut.
image

Is there a way to add it without clearing the preferences?

@calixtus
Copy link
Member

calixtus commented Jul 9, 2024

maybe a preference migration must be added to test if there is already a shortcut registered, and if not, do so?

@HoussemNasri
Copy link
Member

maybe a preference migration must be added to test if there is already a shortcut registered, and if not, do so?

Exactly.

Clearing preferences works because when you pass an empty list of bindings to KeyBindingRepository (which are meant to be loaded from preferences but prefs is cleared now) it would loop through all items in the KeyBinding enum and set the binding to their default.

We should have a migration strategy that would merge the bindings loaded from preferences and key bindings from KeyBinding, keeping the binding set by the user and loaded from preferences if it exists and setting the default value if it does not.

The migration can be added to JabRefPreferences#getKeyBindingRepository where it would synchronize the KeyBinding enum and preferences, by removing values from preferences that are not present in KeyBinding and adding values to preferences that are present in KeyBinding but not in preferences to their default value.

We should also consider versioning preferences because doing the migration could cause problems when running an older version of JabRef.

No version in the path of prefs.xml:
image

@calixtus
Copy link
Member

calixtus commented Jul 9, 2024

Note that the current impl of the preferences default map will change soon

@LoayGhreeb
Copy link
Collaborator Author

Note that the current impl of the preferences default map will change soon

Should I make any changes to the preferences in this PR? This issue is related to the preference design, and it's not ideal to add a preference migration for every new shortcut.

@HoussemNasri
Copy link
Member

Should I make any changes to the preferences in this PR? This issue is related to the preference design, and it's not ideal to add a preference migration for every new shortcut.

I think we should postpone it until the default map change is completed to avoid any conflicts. Plus I have noticed other keybindings are not present in preferences, so the issue goes beyond this PR. I created an issue to track it https://github.com/JabRef/jabref-issue-melting-pot/issues/471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants