Skip to content

Functionality to modify CSL bibliography title and format#12784

Merged
subhramit merged 47 commits into
JabRef:mainfrom
priyanshu16095:titleAndFormat
Mar 29, 2025
Merged

Functionality to modify CSL bibliography title and format#12784
subhramit merged 47 commits into
JabRef:mainfrom
priyanshu16095:titleAndFormat

Conversation

@priyanshu16095

@priyanshu16095 priyanshu16095 commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

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)

Comment thread src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java Outdated
Comment thread src/main/java/org/jabref/gui/openoffice/ModifyBibliographyTitleDialog.java Outdated
Comment thread src/main/java/org/jabref/gui/openoffice/ModifyBibliographyTitleDialog.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
@priyanshu16095

priyanshu16095 commented Mar 20, 2025

Copy link
Copy Markdown
Contributor Author
Recording.2025-03-20.mp4

Works fine!

Comment thread src/main/java/org/jabref/logic/openoffice/Format.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java Outdated
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
Copy Markdown
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).

@subhramit subhramit Mar 25, 2025

Copy link
Copy Markdown
Member

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.

@priyanshu16095 priyanshu16095 Mar 25, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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.

Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
@subhramit

Copy link
Copy Markdown
Member

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

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Few more changes.

Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/oocsltext/Format.java Outdated
Comment thread src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java Outdated
Comment thread src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java Outdated
@subhramit

Copy link
Copy Markdown
Member

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

@subhramit

subhramit commented Mar 25, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
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 subhramit added the status: changes-required Pull requests that are not yet complete label Mar 26, 2025
subhramit
subhramit previously approved these changes Mar 27, 2025

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

My PRs caused this breakage, will fix.

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
Copy Markdown

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
Copy Markdown
Member

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

@trag-bot

trag-bot Bot commented Mar 29, 2025

Copy link
Copy Markdown

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

@subhramit

Copy link
Copy Markdown
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
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>
subhramit added a commit to subhramit/jabref that referenced this pull request May 7, 2025
Signed-off-by: subhramit <subhramit.bb@live.in>
Comment on lines +29 to +30
cslBibliographyTitle.bindBidirectional(openOfficePreferences.cslBibliographyTitleProperty());
cslBibliographySelectedHeaderFormat.bindBidirectional(openOfficePreferences.cslBibliographyHeaderFormatProperty());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These direct bindings here are too sensitive - will capture and save updates regardless of whether a "save/ok" button is pressed, will be changing them in an upcoming PR.

github-merge-queue Bot pushed a commit that referenced this pull request May 7, 2025
* Introduce bibliography body formats (fix code from #13050)

Co-authored-by: DTT12912 <derictonythomas@gmail.com>
Co-authored-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>

* Get hanging indent working

Signed-off-by: subhramit <subhramit.bb@live.in>

* Remove redundant AI comment

Signed-off-by: subhramit <subhramit.bb@live.in>

* Fix JabRef formatting infra

Signed-off-by: subhramit <subhramit.bb@live.in>

* Remove redundant comment

Signed-off-by: subhramit <subhramit.bb@live.in>

* Temp commit

Signed-off-by: subhramit <subhramit.bb@live.in>

* Revert "Temp commit"

This reverts commit 1174ca0.

* Remove unused constant

Signed-off-by: subhramit <subhramit.bb@live.in>

* Rename adapter, remove redundant comment

Signed-off-by: subhramit <subhramit.bb@live.in>

* Remove commented code

Signed-off-by: subhramit <subhramit.bb@live.in>

* Swap order of conditions

Signed-off-by: subhramit <subhramit.bb@live.in>

* wip

Signed-off-by: subhramit <subhramit.bb@live.in>

* wip

Signed-off-by: subhramit <subhramit.bb@live.in>

* Selective override of preferences

Signed-off-by: subhramit <subhramit.bb@live.in>

* Use list instead of enum

Signed-off-by: subhramit <subhramit.bb@live.in>

* Rename variables

Signed-off-by: subhramit <subhramit.bb@live.in>

* Rename with lambda

Signed-off-by: subhramit <subhramit.bb@live.in>

* Add setters

Signed-off-by: subhramit <subhramit.bb@live.in>

* Fix bindings introduced in #12784

Signed-off-by: subhramit <subhramit.bb@live.in>

* Simplify button logic

Signed-off-by: subhramit <subhramit.bb@live.in>

* Shift to OO Panel, complete pref behavior

Signed-off-by: subhramit <subhramit.bb@live.in>

* Add more style options

Signed-off-by: subhramit <subhramit.bb@live.in>

* Replace unused variables

Signed-off-by: subhramit <subhramit.bb@live.in>

* Rename variables

Signed-off-by: subhramit <subhramit.bb@live.in>

* Remove default indent

Signed-off-by: subhramit <subhramit.bb@live.in>

* Remove unused import

Signed-off-by: subhramit <subhramit.bb@live.in>

* Add comment

Signed-off-by: subhramit <subhramit.bb@live.in>

* Add property button disable condition

Signed-off-by: subhramit <subhramit.bb@live.in>

* Localization keys

Signed-off-by: subhramit <subhramit.bb@live.in>

* Fix tests, add changelog entries

Signed-off-by: subhramit <subhramit.bb@live.in>

* Add links to changelog entries

Signed-off-by: subhramit <subhramit.bb@live.in>

* Refine comment

Signed-off-by: subhramit <subhramit.bb@live.in>

* Add note

Signed-off-by: subhramit <subhramit.bb@live.in>

---------

Signed-off-by: subhramit <subhramit.bb@live.in>
Co-authored-by: DTT12912 <derictonythomas@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