-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add setting: always add "Cited on pages" text to JStyles. #11732
Add setting: always add "Cited on pages" text to JStyles. #11732
Conversation
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.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
You can check review dog's comments at the tab "Files changed" of your pull request.
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.
Hey, thanks for taking out time to work on this.
You have gotten the preferences part right, as well as the UI (except for the change listener - check review comments).
Regarding the backend - the following variable is still always set to false, which still renders the functionality useless:
private final boolean alwaysAddCitedOnPages; // TODO (see comment above) |
Please update it's state according to the user's selection. Should be easy passing it to OOBibBase
, see how the other settings are evaluated there. The issue references a PR where I worked on another setting, which was also always set to false before - you can take a hint from there.
I have also left some general comments. I also suggest going through the issue once again for more clarity.
OpenOfficePreferences openOfficePreferences = preferencesService.getOpenOfficePreferences(); | ||
|
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.
Any reason why this was moved? Initializations are usually done at the beginning of the scope.
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.
Personal practice is to initialize as close to first usage as possible to increase refactorability, but if it's project standard to initialize at the beginning, then I will gladly undo.
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.
Yes, there is no general hard-and-fast best practice regarding this. Beginning-of-scope-initialization is preferred when a dependency is used throughout the scope multiple times in logically segregated segments. Near-first-use-initialization is used if the usage is confined, and refactorability is indeed the argument.
I would have requested you to change back, but since moving it to the class level (my comment below on refactoring) will anyway do it at a more global level, this line will just be removed from here.
@@ -657,4 +661,15 @@ private ContextMenu createSettingsPopup() { | |||
|
|||
return contextMenu; | |||
} | |||
|
|||
private void addAlwaysCitedOnPagesTextOption(ContextMenu contextMenu) { | |||
OpenOfficePreferences openOfficePreferences = preferencesService.getOpenOfficePreferences(); |
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.
Additional request for refactor (since we're here): If we require openOfficePreferences
inside multiple methods, we can declare it at class-level and call the getter just once.
Note: Actually, it is slightly bad design that the entire preferencesService
is passed to this class' constructor (not your fault). Could be abstracted, but that's out of scope for this PR an would require more effort to change. You can just do what I mentioned above.
private void addAlwaysCitedOnPagesTextOption(ContextMenu contextMenu) { | ||
OpenOfficePreferences openOfficePreferences = preferencesService.getOpenOfficePreferences(); | ||
|
||
CheckMenuItem alwaysAddCitedOnPagesText = new CheckMenuItem(Localization.lang("Automatically add \"Cited on pages...\" at beginning of citation")); |
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.
-
"Citation" is the text (that is a pointer to a reference) we have in the document. "Bibliography" is the section where we have a list of the references used in the document. A reference could have been cited on multiple pages. So, "Cited on pages" should be there in a bibliographic entry, not a citation.
-
Do you know how to use JabRef's LibreOffice plugin? If yes, can you check where the "Cited on pages" is actually showing up? If no, check out https://docs.jabref.org/cite/openofficeintegration. Ignore the properties part, use a default JStyle. @ThiloteE can also try this out if he has time. I am a bit unsure if "Cited on pages..." should actually come before or after an entry. Whatever it is, we don't have to change the functionality, only the text.
Tl;dr - change "citation" -> "bibliographic entries", "beginning of" -> (wherever it shows up)
Update: Can't test where it appears before work on the backend 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.
I (seemingly) managed to integrate my running JabRef program with LibreOffice, but the "Cited on pages" text didn't appear anywhere in the citation or bibliography.
This is the output I got when using the "Cite" button after selecting an entry in the list. Do I need to write in the actual addition of the text whenever the new setting is active, hence why it isn't appearing? I'm still not completely sure about the boundary between this ticket and what's already been done, but will continue to figure out what exactly is missing, barring input from your side.
Edit: Re-read your main review comment. Need to still update OOBibBase
. Will do now.
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.
Good job. It definitely should be at the end of the citation. "backref", which is part of the hyperref package offers the "cited on pages" feature for LaTeX documents, so that could serve as an inspiration. I do not remember exactly, but I believe I made some minor adjustments to the default backref settings, so that it always starts in a new line, which I think looks slick :-)
Here an example from a paper I wrote in LaTeX that includes backref:
@@ -1132,6 +1132,7 @@ Unable\ to\ reload\ style\ file=Unable to reload style file | |||
|
|||
Problem\ during\ separating\ cite\ markers=Problem during separating cite markers | |||
|
|||
Automatically\ add\ "Cited\ on\ pages..."\ at\ beginning\ of\ citation=Automatically add "Cited on pages..." at beginning of citation |
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.
Text needs to be changed (see comment above for line 668).
alwaysAddCitedOnPagesText.selectedProperty().set(openOfficePreferences.getAlwaysAddCitedOnPages()); | ||
alwaysAddCitedOnPagesText.setOnAction(e -> openOfficePreferences.setAlwaysAddCitedOnPages(alwaysAddCitedOnPagesText.isSelected())); | ||
|
||
contextMenu.getItems().add(alwaysAddCitedOnPagesText); |
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.
-
Once added, this is never removed.
In the issue, I had hinted on using a listener for the style type. We have to use it, otherwise once a JStyle is selected, this will always appear in the settings even if we select a CSL style afterwards. -
Can you add this below the option "Automatically sync bibliography when inserting citations" instead of above it? Reason: The pre-existing option should stay where it was, the new one should be added after it for the user's convenience.
-
For design uniformity, you can also unify the code in this function into the existing
createSettingsPopup()
. Reason: Although delegating into separate functions makes code cleaner to read, each function of this class deals with a high-level activity.
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'm really embarrassed I forgot about the CSL Styles, will add the removal mechanism and move the item below the "old" option as requested.
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'm really embarrassed I forgot about the CSL Styles, will add the removal mechanism and move the item below the "old" option as requested.
Please be comfortable, you are new to the codebase, so that's very normal!
Removed in #11733 |
The new option's presence now based on selected style, with presence being ensured only if the style is a JStyle. The option now appears always first from the top, using index based insertion to achieve this. The text has been updated to reference bibliographic entries as opposed to citations, which was factually incorrect.
Reference existing preference in OOBibBase to properly propagate setting, so that "Cited on pages" text literal will appear when user has it configured. Remove accomplished TODOs.
Great work, Austin! Everything works now, tests are green too. Only one last thing to fix - you have accidentally committed submodules (see
And similarly for To avoid this: avoid using Context: JabRef needs submodules such as CSL style files for some of its respective features. When setting up a local development environment, these are cloned once using |
except for the submodule stuff it looks good from my side! Thanks for your contribution and the hopefully onoging interest in JabRef! |
…ays-add-cited-on-pages-text-setting
Regarding the submodules:
|
Right now, the desired change would be that you sync the submodules in your PR (hence your branch) with the ones in
Yes, |
The problem with submodules is often when you create a new branch with IntelliJ, it will create a new branch for the submodules as well. If you now fetch the latest updates in IntelliJ it will update the submodules as well and ignore the "pinned" commit from main. In the commit window, it will now list the changes to the submodules as well. One has to explicit uncheck them TL;DR: reset submodules cd buildres/abbrv.jabref.org same for csl styles: use git gui to commit submodule changes only. |
.gitmodules
Outdated
@@ -1,15 +1,15 @@ | |||
[submodule "abbrv.jabref.org"] | |||
path = buildres/abbrv.jabref.org | |||
url = https://github.com/JabRef/abbrv.jabref.org.git | |||
ignore = all | |||
# ignore = all |
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.
see my latest comment for a TL;DR (git submodules are a pain in the a**)
Thank you two very much for the help! I believe the submodule changes are synced again. |
@heyitsdross by the way, if you use "Closes" in your PR description, it is treated as a keyword and the issue is linked automatically. |
So that's how that works! Very nice :) |
@heyitsdross Thanks again for your PR! Keep up the good work :) |
Closes #11691
Draft PR for coding feedback
TODO (for me):
[] Update user documentation, open documentation PR.
[] Review developer documentation to see if update necessary. (I think it's unlikely).
To Test:
View > OpenOffice/LibreOffice
(orAlt + 0
)Screenshot Preview of feature:
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)