Skip to content

Implement reset for Name Display Preferences#15136

Merged
calixtus merged 8 commits intoJabRef:mainfrom
RakockiW:fix-for-issue-14412
Mar 2, 2026
Merged

Implement reset for Name Display Preferences#15136
calixtus merged 8 commits intoJabRef:mainfrom
RakockiW:fix-for-issue-14412

Conversation

@RakockiW
Copy link
Copy Markdown
Contributor

@RakockiW RakockiW commented Feb 16, 2026

Related issues and pull requests

Closes #14412

PR Description

Hello! I followed the steps in #14400 and implemented resetting for Name Display Preferences.

Steps to test

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • [/] I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • [/] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@github-actions
Copy link
Copy Markdown
Contributor

Hey @RakockiW! 👋

Thank you for contributing to JabRef!

We have automated checks in place, based on which you will soon get feedback if any of them are failing. We also use Qodo for review assistance. It will update your pull request description with a review help and offer suggestions to improve the pull request.

After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs. You can read about the whole pull request process in our contribution guide.

Please ensure that your pull request is in line with our AI Usage Policy and make necessary disclosures.

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Implement reset functionality for Name Display Preferences

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add reset functionality for Name Display Preferences
• Implement getDefault() and setAll() methods in NameDisplayPreferences
• Remove hardcoded preference defaults from JabRefGuiPreferences
• Integrate name display preferences into reset and import workflows
Diagram
flowchart LR
  NDP["NameDisplayPreferences"]
  NDP -->|"add getDefault()"| NDP2["Default instance"]
  NDP -->|"add setAll()"| NDP3["Update preferences"]
  JRP["JabRefGuiPreferences"]
  JRP -->|"remove hardcoded defaults"| JRP2["Cleaner config"]
  JRP -->|"add getNameDisplayPreferencesFromBackingStore()"| JRP3["Load from storage"]
  JRP2 -->|"integrate into clear()"| RESET["Reset workflow"]
  JRP3 -->|"integrate into importPreferences()"| IMPORT["Import workflow"]
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java ✨ Enhancement +16/-0

Add reset and default methods to NameDisplayPreferences

• Add private no-arg constructor with default values (NATBIB display style, LASTNAME_ONLY
 abbreviation)
• Add getDefault() static method to create default instance
• Add setAll() method to update both display style and abbreviation style from another instance

jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java


2. jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java ✨ Enhancement +11/-11

Integrate name display preferences into reset and import

• Remove hardcoded name display preference defaults from initialization
• Add getNameDisplayPreferencesFromBackingStore() method to load preferences from backing store
• Integrate name display preferences reset into clear() method
• Integrate name display preferences import into importPreferences() method
• Update getNameDisplayPreferences() to use backing store loader instead of direct instantiation

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java


Grey Divider

Qodo Logo

@github-actions github-actions bot added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Feb 16, 2026
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Feb 16, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Null-unsafe setAll 📘 Rule violation ⛯ Reliability
Description
NameDisplayPreferences.setAll dereferences preferences without a null/edge-case guard, which can
cause a runtime NullPointerException. This violates the requirement to explicitly handle null/edge
cases at potential failure points.
Code

jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java[R36-38]

+    public void setAll(NameDisplayPreferences preferences) {
+        this.displayStyle.set(preferences.displayStyle.get());
+        this.abbreviationStyle.set(preferences.abbreviationStyle.get());
Evidence
The robustness rule requires explicit handling of null/edge cases; the newly added public setAll
method directly accesses preferences.displayStyle and preferences.abbreviationStyle without
validating preferences first.

Rule 3: Generic: Robust Error Handling and Edge Case Management
jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java[36-38]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`NameDisplayPreferences.setAll` can throw a `NullPointerException` if called with a null `preferences` argument.
## Issue Context
This method is public and is used to reset/import preferences; it should be resilient to null/edge cases per robustness requirements.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java[36-39]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Reset behavior untested 📘 Rule violation ✓ Correctness
Description
The PR changes preference reset/import behavior for name display settings but does not add/update
tests to cover the new behavior. This risks regressions in preferences clearing/importing logic.
Code

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java[347]

+        getNameDisplayPreferences().setAll(NameDisplayPreferences.getDefault());
Evidence
The compliance checklist requires behavior changes to be covered by tests; this PR modifies
clear() and importPreferences(...) behavior for NameDisplayPreferences, and the PR description
indicates JUnit tests were not added.

AGENTS.md
jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java[327-372]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The updated reset/import logic for `NameDisplayPreferences` is not covered by tests.
## Issue Context
`JabRefGuiPreferences.clear()` and `JabRefGuiPreferences.importPreferences(...)` now call `getNameDisplayPreferences().setAll(...)`, and backing-store parsing logic was refactored; tests should assert the resulting `DisplayStyle`/`AbbreviationStyle` values for representative stored preference combinations.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java[327-372]
- jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java[925-990]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines +1228 to +1232
private NameDisplayPreferences getNameDisplayPreferencesFromBackingStore(NameDisplayPreferences defaults) {
return new NameDisplayPreferences(
defaults.getDisplayStyle(),
defaults.getAbbreviationStyle());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. getnamedisplaypreferencesfrombackingstore ignores store 📘 Rule violation ✓ Correctness

getNameDisplayPreferencesFromBackingStore is named as if it reads persisted values, but it only
copies fields from defaults, so stored/imported preferences can be silently ignored. This violates
the requirement for self-documenting naming because the identifier does not match actual behavior.
Agent Prompt
## Issue description
`getNameDisplayPreferencesFromBackingStore` is misleading and currently does not read from the backing store. It only returns values from the `defaults` argument, which can cause persisted/imported name display preferences to be ignored.

## Issue Context
Other `*FromBackingStore` helpers in this class read values via `getBoolean/getInt/...` with a fallback to `defaults`. Name display preferences should follow the same pattern (or the method should be renamed if it is intentionally default-only).

## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java[930-930]
- jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java[1228-1232]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@RakockiW RakockiW marked this pull request as draft February 16, 2026 23:21
@testlens-app

This comment has been minimized.

@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete status: no-bot-comments and removed status: no-bot-comments status: changes-required Pull requests that are not yet complete labels Feb 17, 2026
@RakockiW RakockiW marked this pull request as ready for review February 17, 2026 20:38
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Implement reset functionality for Name Display Preferences

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add reset functionality for Name Display Preferences
• Implement getDefault() and setAll() methods in NameDisplayPreferences
• Refactor preference loading to use backing store with proper defaults
• Remove hardcoded preference defaults from JabRefGuiPreferences
• Integrate reset into preferences clear operation
Diagram
flowchart LR
  A["NameDisplayPreferences"] -->|"add getDefault()"| B["Default preferences"]
  A -->|"add setAll()"| C["Reset mechanism"]
  D["JabRefGuiPreferences"] -->|"refactor loading"| E["getNameDisplayPreferencesFromBackingStore()"]
  E -->|"use defaults"| B
  F["clear() method"] -->|"call setAll()"| C
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java ✨ Enhancement +16/-0

Add default and reset methods to preferences class

• Add private no-arg constructor with default values (NATBIB, FULL)
• Add getDefault() static method to create default preferences instance
• Add setAll() method to copy preferences from another instance

jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java


2. jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java ✨ Enhancement +41/-28

Refactor name display preferences loading and reset

• Remove hardcoded preference defaults for name display settings
• Add getNameDisplayPreferencesFromBackingStore() method to load from backing store
• Refactor getNameDisplayStyle() and getNameAbbreviationStyle() into separate backing store
 methods with proper default fallback
• Integrate getNameDisplayPreferences().setAll(NameDisplayPreferences.getDefault()) into clear()
 method
• Integrate backing store loading into importPreferences() method
• Update getNameDisplayPreferences() to use backing store loader

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java


Grey Divider

Qodo Logo

@koppor koppor marked this pull request as draft February 17, 2026 20:38
@RakockiW
Copy link
Copy Markdown
Contributor Author

Hi, I would be grateful if you could give me feedback on whether my approach in the method getNameDisplayPreferencesFromBackingStore is correct.
I do explicit handling for the "all flags false" case to correctly restore LASTNAME_FIRSTNAME and NONE, since there are no dedicated enums for these values.

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit f9577d1

@RakockiW RakockiW marked this pull request as ready for review February 17, 2026 22:40
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Implement reset functionality for Name Display Preferences

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add reset functionality for Name Display Preferences
• Implement getDefault() and setAll() methods in NameDisplayPreferences
• Refactor preference loading to use backing store with proper defaults
• Remove hardcoded preference defaults from JabRefGuiPreferences
• Integrate name display preferences reset into global preferences clear method
Diagram
flowchart LR
  A["NameDisplayPreferences"] -->|"add getDefault()"| B["Default preferences"]
  A -->|"add setAll()"| C["Reset mechanism"]
  D["JabRefGuiPreferences"] -->|"refactor loading"| E["getNameDisplayPreferencesFromBackingStore()"]
  E -->|"use defaults"| B
  D -->|"integrate reset"| F["clear() method"]
  F -->|"calls setAll()"| C
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java ✨ Enhancement +16/-0

Add default and reset methods to preferences class

• Add private no-argument constructor with default values (NATBIB display style and FULL
 abbreviation style)
• Add getDefault() static method to create default preferences instance
• Add setAll() method to copy preferences from another instance

jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java


2. jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java ✨ Enhancement +41/-28

Refactor name display preferences loading and reset integration

• Remove hardcoded preference defaults for name display settings from defaults map
• Add getNameDisplayPreferencesFromBackingStore() method to load preferences with fallback to
 defaults
• Refactor getNameDisplayStyle() and getNameAbbreviationStyle() into
 getNameDisplayStyleFromBackingStore() and getNameAbbreviationStyleFromBackingStore() with proper
 default handling
• Integrate name display preferences reset into clear() method
• Integrate name display preferences import into importPreferences() method
• Update getNameDisplayPreferences() to use backing store loader

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java


Grey Divider

Qodo Logo

@koppor koppor marked this pull request as draft February 17, 2026 22:40
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit b95cf28

@RakockiW RakockiW marked this pull request as ready for review February 17, 2026 23:06
@koppor koppor marked this pull request as draft February 17, 2026 23:06
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Implement reset functionality for Name Display Preferences

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add reset functionality for Name Display Preferences
• Implement getDefault() and setAll() methods in NameDisplayPreferences
• Refactor preference loading to use backing store with proper defaults
• Remove hardcoded preference defaults from JabRefGuiPreferences
• Integrate name display preferences reset into clear() and importPreferences() methods
Diagram
flowchart LR
  A["NameDisplayPreferences"] -->|"add getDefault()"| B["Default preferences"]
  A -->|"add setAll()"| C["Update preferences"]
  D["JabRefGuiPreferences"] -->|"remove hardcoded defaults"| E["Cleaner initialization"]
  D -->|"add getNameDisplayPreferencesFromBackingStore()"| F["Load from backing store"]
  G["clear() method"] -->|"call setAll(getDefault())"| H["Reset to defaults"]
  I["importPreferences() method"] -->|"call setAll(getFromBackingStore())"| J["Restore from storage"]
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java ✨ Enhancement +16/-0

Add default and bulk update methods

• Add private no-argument constructor with default values
• Add getDefault() static method to create default preferences instance
• Add setAll() method to update all preference values from another instance

jabgui/src/main/java/org/jabref/gui/maintable/NameDisplayPreferences.java


2. jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java ✨ Enhancement +41/-28

Refactor name display preferences loading and reset

• Remove hardcoded preference defaults for name display settings from defaults map
• Add getNameDisplayPreferencesFromBackingStore() method to load preferences from backing store
• Refactor getNameDisplayStyle() and getNameAbbreviationStyle() into separate backing store
 methods with proper default fallback logic
• Integrate name display preferences reset in clear() method
• Integrate name display preferences restoration in importPreferences() method
• Update getNameDisplayPreferences() to use backing store loader instead of direct initialization

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java


Grey Divider

Qodo Logo

@RakockiW RakockiW marked this pull request as ready for review February 17, 2026 23:06
@RakockiW RakockiW force-pushed the fix-for-issue-14412 branch from 373ebd4 to 0352567 Compare March 1, 2026 21:28
@testlens-app

This comment has been minimized.

@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete status: no-bot-comments and removed status: no-bot-comments status: changes-required Pull requests that are not yet complete labels Mar 1, 2026
@RakockiW RakockiW force-pushed the fix-for-issue-14412 branch from 0352567 to ad6c30c Compare March 1, 2026 21:40
@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@RakockiW
Copy link
Copy Markdown
Contributor Author

RakockiW commented Mar 1, 2026

Sorry, thanks for poining that out.

Comment on lines +937 to +947
System.out.println(NAMES_NATBIB + ": " + newValue);
putBoolean(NAMES_AS_IS, newValue == NameDisplayPreferences.DisplayStyle.AS_IS);
System.out.println(NAMES_AS_IS + ": " + newValue);
putBoolean(NAMES_FIRST_LAST, newValue == NameDisplayPreferences.DisplayStyle.FIRSTNAME_LASTNAME);
System.out.println(NAMES_FIRST_LAST + ": " + newValue);
});
EasyBind.listen(nameDisplayPreferences.abbreviationStyleProperty(), (obs, oldValue, newValue) -> {
putBoolean(ABBR_AUTHOR_NAMES, newValue == NameDisplayPreferences.AbbreviationStyle.FULL);
System.out.println(ABBR_AUTHOR_NAMES + ": " + newValue);
putBoolean(NAMES_LAST_ONLY, newValue == NameDisplayPreferences.AbbreviationStyle.LASTNAME_ONLY);
System.out.println(NAMES_LAST_ONLY + ": " + newValue);
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.

What happend here?

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.

Deleted, sorry.

@testlens-app

This comment has been minimized.

@RakockiW RakockiW requested a review from calixtus March 1, 2026 22:12
@testlens-app

This comment has been minimized.

@testlens-app
Copy link
Copy Markdown

testlens-app bot commented Mar 2, 2026

✅ All tests passed ✅

🏷️ Commit: 943707d
▶️ Tests: 11252 executed
⚪️ Checks: 50/50 completed


Learn more about TestLens at testlens.app.

@calixtus calixtus added this pull request to the merge queue Mar 2, 2026
@github-actions github-actions bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Mar 2, 2026
Merged via the queue into JabRef:main with commit c12efc0 Mar 2, 2026
50 checks passed
@RakockiW RakockiW deleted the fix-for-issue-14412 branch March 2, 2026 20:55
priyanshu16095 pushed a commit to priyanshu16095/jabref that referenced this pull request Mar 3, 2026
* Implement reset for NameDisplayPreferences

* Fixed implemention of getNameDisplayPreferencesFromBackingStore method

* refactor

* deleted sout statements
Siedlerchr added a commit that referenced this pull request Mar 5, 2026
…rg.openrewrite.recipe-rewrite-recipe-bom-3.25.0

* upstream/main: (35 commits)
  Chore: add dependency-management.md (#15278)
  Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (#15277)
  New Crowdin updates (#15274)
  Chore(deps): Bump actions/upload-artifact from 6 to 7 (#15271)
  Chore(deps): Bump actions/download-artifact from 7 to 8 (#15270)
  Chore(deps): Bump docker/login-action from 3 to 4 (#15268)
  Fix threading issues in citations relations tab (#15233)
  Fix: Citavi XML importer now preserves citation keys (#14658) (#15257)
  Preserve no break spaces in Latex to Unicode conversion (#15174)
  Fix: open javafx.scene.control.skin to controlsfx (#15260)
  Reduce complexity in dependencies setup (restore) (#15194)
  New translations jabref_en.properties (French) (#15256)
  Fix: exception dialog shows up when moving sidepanel down/up (#15248)
  Implement reset for Name Display Preferences (#15136)
  Chore(deps): Bump net.bytebuddy:byte-buddy in /versions (#15252)
  Chore(deps): Bump io.zonky.test.postgres:embedded-postgres-binaries-bom (#15253)
  Chore(deps): Bump io.zonky.test:embedded-postgres in /versions (#15254)
  Chore(deps): Bump net.ltgt.errorprone from 5.0.0 to 5.1.0 in /jablib (#15251)
  New Crowdin updates (#15247)
  Refined the "Select files to import" page in "Search for unlinked local files" dialog (#15110)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first contrib good first issue An issue intended for project-newcomers. Varies in difficulty. status: no-bot-comments status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable resetting of NameDisplayPreferences

2 participants