-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Show compound patterns in the dropdown for citation key patterns #12580
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
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
public List<String> generateCompoundPatterns(String enteredText) { | ||
List<String> patterns = List.of("auth", "edtr", "year", "title", "date"); |
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.
@subhramit I used this list as I don’t have much knowledge about the fields and can you explain more about compound patterns?
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 use the constants of org.jabref.model.entry.field.StandardField here.
The fields can be read about at BibLaTeX documentation at https://ctan.org/pkg/biblatex.
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.
I think, the list should be manually crafted instead of just combinding all fields
The description at #12502 (comment) talks about auto completion
That would be nice.
If this is not possible, some pre-selected combinations should be doable.
I think, it needs to be a separate pop up then - even if multiple modals are not a good style ^^
Grammar: [{pattern}](_[{pattern}])*
- A user can select a pattern.
- Then, the user can select "+"
- Then, JabRef adds "_" and offers another dropdown to select (the one selected before is NOT offered)
Reason: A user wants to use AuthEtAl together with year typically.
@priyanshu16095 Think of this as autogenerated (!) human-readable-primary-key in databases. MAybe this helps. -- Another thing: Either data of a BibEntry can be used directly or some processing of JabRef can be used. The former is ensured by CAPITAL LETTERS (first paragraph at https://docs.jabref.org/setup/citationkeypatterns#citation-key-patterns). The latter is described in the other text.
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.
JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.
Recording.2025-02-28.mp4@koppor Thanks for your insights! I’ve come up with a different solution that addresses the concerns and removes the overhead of an algorithm, maintaining it, and making it more efficient. |
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.
JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.
Sorry, I am a little low on time to test this - What does the menu "Create compound pattern" do? Why is it needed if we can create compound patterns by taking patterns from the "All patterns" list? As far as I understand, only thing it does is add underscores in between patterns - the choice of that separator can be arbitrary for a user. @koppor do we wish to make underscore a default for this? Or is it a wider convention? This user, for example, was using colons ( @priyanshu16095 Can you move the black arrows of the first menu (first two items having sublists) to the extreme right of the cell (like in the sublist menu)? (Updated) |
Just like a dropdown that shows generated compound patterns, it allows the user to create any pattern on their own. |
@koppor ping |
Good idea! |
The functionality is unclear because of the wording. The options need to be "parallel", like this: Example 1
Example 2
Example 3
What about modifiers? These could be available after the first field or field marker has been selected, maybe like this. Example 4
Another possibility for modifiers and even more detail would be to include an "expert" option linking to documentation or just add |
@ryan-carpenter I was unable to convey this properly. What I mean to say is that, without writing much additional code and by simply adding a few lines in the UI, it significantly improves the user experience. This is because there's no need to read any documentation or manually reopen the dropdown. |
What is described in the comment is too complex to be implemented with context menu. If adding a submenu for other symbols and an expert linked to documentation is sufficient, or else I should use any other thing for UI. |
I am okay with doing what is described in the comment. Just want to know thoughts on this. |
Lets do a follow-up on that in a separate PR. |
Done, resolved the conflicts, and it is ready. |
Does it also require a changelog.md entry? |
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of |
Fixing the checks... |
No, if the previous one mentions "dropdowns". Else, you can edit it. |
private int heightOfMenuItem; | ||
private final StringBuilder selectedPatterns = new StringBuilder(); |
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.
StringBuilder is used for concatenating strings, which can be replaced with StringJoiner for better readability and maintainability.
CitationKeyPattern.Category.BIBENTRY_FIELDS, Localization.lang("Entry fields") | ||
); | ||
Map<CitationKeyPattern.Category, String> categoryNames = new LinkedHashMap<>(); | ||
categoryNames.put(CitationKeyPattern.Category.AUTHOR_RELATED, Localization.lang("Author related")); |
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.
The localization strings should be prefixed with % for proper localization handling in JabRef.
@@ -131,7 +149,8 @@ private void populatePopup(List<String> searchResult) { | |||
} | |||
|
|||
suggestionsList.getItems().clear(); | |||
suggestionsList.getItems().add(createPatternsSubMenu()); | |||
suggestionsList.getItems().add(ALL_PATTERNS_POSITION, createPatternsSubMenu()); |
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.
The use of magic numbers like ALL_PATTERNS_POSITION should be avoided. Consider using a more descriptive constant or comment.
You ticked that you modified If you made changes that are visible to the user, please add a brief description along with the issue number to the |
It's ready. Please take a look at the trag bot review and let me know what needs to be done in the follow-up. |
if (!newValue) { | ||
suggestionsList.hide(); | ||
} |
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.
The code should follow the fail-fast principle by immediately handling invalid states and returning early instead of nesting logic inside else branches.
This is complete. |
@subhramit This is complete. |
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.
For any user-visible change, there should be a CHANGELOG.md entry.
Counter-Intuitive for me
context menu (right-click) does not show any suggestions:
When pressing a letter, the menu is shown.
Why empty?
--
The number of entries at compound-patterns is not limited, thus [author]_[title]_[year]
is also valid
I think, more intuitive would be:
- Show only "All patterns" during completion.
- Show completion also after
_
- Show completion also at right click
- Remove "Compound pattern"
Future work: context menu INSIDE a pattern shows the available modifiers.
positionCaret(selectedPatterns.length()); | ||
suggestionsList.hide(); | ||
selectionCount = 0; | ||
selectedPatterns.setLength(0); |
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.
Not understandable at first sight - comment needed.
suggestionsList.show(this, screenX, screenY); | ||
} | ||
} else if (selectionCount == 1) { | ||
selectedPatterns.append("_").append(pattern.stringRepresentation()); |
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.
Not sure how this whole things works. Somewhere, it should be explained, how selectedPatterns
is inteded to be sued.
I think, my review even improves usability more - and should not be much code, either. What ryan also mentioned are the modifiers - which I also mentioned in my comment. On the one hand, this is really advanced JabRef usage - and could be done in a follow up. On the other hand, if you start implementing context menus, this could be "easily" doable maybe. |
My main intent was to point out that the wording "All patterns" and "Create compound pattern" could be improved. The first is a noun phrase and the second is a verb phrase, which takes a little longer to process than if they are both the same. Example 1 is a suggestion that uses only verb-phrases while Examples 2 and 3 are alternatives that using only noun-phrases. I also noticed that it might not be clear that "Create compound pattern" would need to be used repeatedly to create the pattern. If I recall correctly the phrase "Add to pattern" would not make sense because the user needs to first pick an initial pattern, then repeat the action to append to it. Example 4 was an additional idea for potentially extending the proposal from priyanshu to become a "complete" pattern builder without requiring a dedicated window/form (because the proposal is already so close to providing this). I agree that if this is to be done, it can be a follow-up issue. Edit: These ideas are also covered in a practical way by koppor's remarks in #12580 (review) |
Follow-up for #12516
This PR enhances the citation key dropdown feature by adding a submenu for compound patterns.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)Recording.2025-02-28.mp4