Skip to content

Functionality to modify CSL bibliography title and format #12784

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

Merged
merged 47 commits into from
Mar 29, 2025

Conversation

priyanshu16095
Copy link
Contributor

@priyanshu16095 priyanshu16095 commented Mar 20, 2025

Closes #12663

This PR adds the functionality to modfy CSL bibliography title and format.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (if change is visible to the user)
  • 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.

Screenshot (250)
Screenshot (252)
Screenshot (253)

@priyanshu16095
Copy link
Contributor Author

priyanshu16095 commented Mar 20, 2025

Recording.2025-03-20.mp4

Works fine!

@@ -176,7 +178,7 @@ public void insertBibliography(XTextCursor cursor, CitationStyle selectedStyle,
throws WrappedTargetException, CreationException {
boolean isNumericStyle = selectedStyle.isNumericStyle();

OOText title = OOFormat.paragraph(OOText.fromString(CSLFormatUtils.DEFAULT_BIBLIOGRAPHY_TITLE), CSLFormatUtils.DEFAULT_BIBLIOGRAPHY_HEADER_PARAGRAPH_FORMAT);
OOText title = OOFormat.paragraph(OOText.fromString(openOfficePreferences.getBibliographyTitle().get()), openOfficePreferences.getHeaderFormat().get());
Copy link
Member

Choose a reason for hiding this comment

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

Instead of fetching the properties via preferences here (which would cause introduction of preferences), once you move the format definitions to CSLFormatUtils, get them from preferences there itself, then use them here (static access).

Copy link
Member

@subhramit subhramit Mar 25, 2025

Choose a reason for hiding this comment

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

@priyanshu16095 Why is this marked resolved even though I still see raw preferences being imported and used here?

I don't mind repeating review comments for first-time contributors, but please understand that right now you are expected to act with a sense of ownership. It takes patience to repeat review comments, more so to check, find and "unresolve" old comments when it seems something has been asked for before. I think I have also repeated to you thrice now - do not resolve comments before they are completely addressed.

Copy link
Contributor Author

@priyanshu16095 priyanshu16095 Mar 25, 2025

Choose a reason for hiding this comment

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

Apologies, I had previously modified the code based on the review, but as per this comment (#12784), I need to use these again. They were resolved earlier.

In this commit bbe688d, I did this as per review .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not clear to me. How do I get them from preferences.

@subhramit
Copy link
Member

I see most changes addressed. I am a bit busy, will give more feedback once I find some time this week.

Copy link
Member

@subhramit subhramit left a comment

Choose a reason for hiding this comment

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

Few more changes.

@subhramit
Copy link
Member

Please request a review once you have addressed all the comments above.

@subhramit
Copy link
Member

subhramit commented Mar 25, 2025

Answering #12784 (comment) here:
This is more of a thought to preserve the design of linear dependency chain withnout jumps, such that all options related to text formatting should be retrieved by CSLCitationOOAdapter from CSLFormatUtils, and not directly from OpenOfficePreferences.

What you have to do is, get the preferences in CSLFormatUtils (import OpenOfficePreferences in that class if not already imported, and not in the adapter) and maybe create two functions with appropriate names, and internally return openOfficePreferences.getBibliographyTitle().get() etc. there. In the adapter, the preference thus should be obtained by a static call without the optional unwrap (get()), e.g.

OOFormat.paragraph(OOText.fromString(CSLFormatUtils.getBibliographyTitle(), CSLFormatUtils.getBibliographyHeaderFormat());

Let me know if this is clear.

@subhramit
Copy link
Member

Let me know if this is clear.

Even better way:

public class CSLFormatUtils {
    
    public static String BIBLIOGRAPHY_TITLE;
    public static String BIBLIOGRAPHY_HEADER_FORMAT;

    public CSLFormatUtils(OpenOfficePreferences openOfficePreferences) {
        BIBLIOGRAPHY_TITLE = openOfficePreferences.cslBibliographyTitle().get();
        BIBLIOGRAPHY_HEADER_FORMAT = openOfficePreferences.cslBibliographyTitle().get();
    }
...

No need of extra functions, and can directly use CSLFormatUtils.BIBLIOGRAPHY_TITLE and so on in the adapter.

I am adding some more review comments to get rid of get() as early as possible.

@subhramit
Copy link
Member

subhramit commented Mar 26, 2025

@priyanshu16095 currently actionable items (as I see) would be the fxml button and localization of strings. I will probably handle the design part later on. Please request me or Ruslan for a review once done (and tested).

@subhramit subhramit added status: changes required Pull requests that are not yet complete and removed status: awaiting second review For non-trivial changes labels Mar 26, 2025
subhramit
subhramit previously approved these changes Mar 27, 2025
Copy link
Member

@subhramit subhramit left a comment

Choose a reason for hiding this comment

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

Tested, can get this in.

@subhramit subhramit added status: awaiting second review For non-trivial changes and removed status: changes required Pull requests that are not yet complete labels Mar 27, 2025
@subhramit
Copy link
Member

My PRs caused this breakage, will fix.

@@ -94,6 +95,7 @@ private void initializeCitationAdapter(XTextDocument doc) throws WrappedTargetEx
OOStyle initialStyle = openOfficePreferences.getCurrentStyle(); // may be a jstyle, can still be used for detecting subsequent style changes in context of CSL
cslCitationOOAdapter = new CSLCitationOOAdapter(doc, databasesSupplier, initialStyle);
cslUpdateBibliography = new CSLUpdateBibliography();
CSLFormatUtils.setBibliographyProperties(openOfficePreferences);
Copy link

Choose a reason for hiding this comment

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

The addition of this line in the initializeCitationAdapter method changes the method's behavior, but the JavaDoc for the method has not been updated to reflect this change, violating instruction 1.

@subhramit
Copy link
Member

@Siedlerchr can you test this once? I think it would be mergeable now.

Copy link

trag-bot bot commented Mar 29, 2025

@trag-bot didn't find any issues in the code! ✅✨

@subhramit
Copy link
Member

Since Ruslan did the second review and I tested it, I am letting this in.

@subhramit subhramit enabled auto-merge March 29, 2025 16:57
@subhramit subhramit added this pull request to the merge queue Mar 29, 2025
@subhramit subhramit removed the status: awaiting second review For non-trivial changes label Mar 29, 2025
Merged via the queue into JabRef:main with commit 993b223 Mar 29, 2025
1 check passed
krishnagjsForGit pushed a commit to krishnagjsForGit/jabref that referenced this pull request May 2, 2025
* Functionality to modify title and header format

* Add CHANGELOG.md entry, rename Formats to Format and address the reviews

* Fix typo in CHANGELOG.md entry

* Rename variables

* Rename variable, remove two methods, fix check

* Rename variables and fix the check

* Rename classes

* Some minor changes

* Renamed variables

* Rename variable

* Remove hardcoded value from constructor

* Rename variable

* Use CSLFormatUtils for title and format

* Remove preference from constructor

* Update JabRefCliPreferences.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Update JabRefCliPreferences.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Update ModifyCSLBibliographyTitleDialogViewModel.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Update ModifyCSLBibliographyTitleDialogViewModel.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Remove static import

* Remove DEFAULT from variable names

* Use getters

* Remove unused methods

* Elaborate changelog entry

* Shorten changelog entry

* Restore methods

* Reduce use of `get()`, better naming for methods

* Use correct function

* Rename controller to view as per MVVM

* More renaming

* Consistent naming in `CliPreferences`

* Fix functionality

* Tragbot comment - resolve architectural violation

* Variable naming convention and Tragbot comment - resolve encapsulation

* Fix preferences

* Remove Heading from Format

* Update CHANGELOG.md

Co-authored-by: Ruslan <ruslanpopov1512@gmail.com>

* Use localized strings

* Fix preferences initialization pipeline

---------

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
Co-authored-by: Ruslan <ruslanpopov1512@gmail.com>
krishnagjsForGit pushed a commit to krishnagjsForGit/jabref that referenced this pull request May 2, 2025
* Functionality to modify title and header format

* Add CHANGELOG.md entry, rename Formats to Format and address the reviews

* Fix typo in CHANGELOG.md entry

* Rename variables

* Rename variable, remove two methods, fix check

* Rename variables and fix the check

* Rename classes

* Some minor changes

* Renamed variables

* Rename variable

* Remove hardcoded value from constructor

* Rename variable

* Use CSLFormatUtils for title and format

* Remove preference from constructor

* Update JabRefCliPreferences.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Update JabRefCliPreferences.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Update ModifyCSLBibliographyTitleDialogViewModel.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Update ModifyCSLBibliographyTitleDialogViewModel.java

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Remove static import

* Remove DEFAULT from variable names

* Use getters

* Remove unused methods

* Elaborate changelog entry

* Shorten changelog entry

* Restore methods

* Reduce use of `get()`, better naming for methods

* Use correct function

* Rename controller to view as per MVVM

* More renaming

* Consistent naming in `CliPreferences`

* Fix functionality

* Tragbot comment - resolve architectural violation

* Variable naming convention and Tragbot comment - resolve encapsulation

* Fix preferences

* Remove Heading from Format

* Update CHANGELOG.md

Co-authored-by: Ruslan <ruslanpopov1512@gmail.com>

* Use localized strings

* Fix preferences initialization pipeline

---------

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
Co-authored-by: Ruslan <ruslanpopov1512@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow user to choose CSL Bibliography title and format
5 participants