Refine Automatic Field Editor filtering logic (fixes #15066)#15094
Conversation
- Updated Clear, Copy/Move, and Rename tabs to show only populated fields by default. - Added a "Show only set fields" checkbox to the Edit tab, enabled by default. - Improved default field selection in ViewModels to prevent empty/ghost placeholders. - Added localization for the new checkbox string. fixes JabRef#15066
|
Hey @betheashvin! 👋 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. |
Review Summary by QodoRefine Automatic Field Editor filtering logic with context-aware field display
WalkthroughsDescription• Implement context-aware field filtering in Automatic Field Editor • Show only populated fields by default across all tabs • Add "Show only set fields" toggle checkbox to Edit tab • Set intelligent default field selection based on actual data Diagramflowchart LR
A["User selects entries"] -->|"Automatic Field Editor"| B["Clear/Copy/Move/Rename tabs"]
B -->|"Filter logic"| C["Show only populated fields"]
A -->|"Edit tab"| D["Toggle checkbox"]
D -->|"Checked"| C
D -->|"Unchecked"| E["Show all BibTeX fields"]
C -->|"Default selection"| F["First populated field"]
File Changes1. jabgui/src/main/java/org/jabref/gui/edit/automaticfiededitor/clearcontent/ClearContentTabView.java
|
Code Review by Qodo
1. Internal fields in Clear tab
|
| Set<Field> setFields = viewModel.getSetFieldsOnly(); | ||
| fieldComboBox.getItems().setAll(setFields); |
There was a problem hiding this comment.
1. Internal fields in clear tab 🐞 Bug ✓ Correctness
Clear Content now fills the dropdown from “set fields” gathered via BibEntry.getFields(), which can include JabRef InternalField values (e.g., citationkey/entrytype). This can expose internal fields that were previously excluded and allow users to clear them, risking data integrity and confusing UI.
Agent Prompt
### Issue description
The Clear Content tab dropdown is now populated from entry.getFields(), which includes JabRef `InternalField`s like `citationkey` and `entrytype`. Those fields were previously excluded via `FieldFactory.getAllFieldsWithOutInternal()`, and exposing them lets users clear internal metadata.
### Issue Context
`BibEntry.getFields()` returns `fields.keySet()`, and JabRef stores internal fields (e.g., citation key/type header) in that map.
### Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/edit/automaticfiededitor/clearcontent/ClearContentViewModel.java[25-34]
- jablib/src/main/java/org/jabref/model/entry/BibEntry.java[430-433]
- jablib/src/main/java/org/jabref/model/entry/field/FieldFactory.java[163-169]
- jablib/src/main/java/org/jabref/model/entry/field/InternalField.java[7-16]
### Suggested change
Adjust `getSetFieldsOnly()` to filter out internal fields, e.g.:
- `filter(field -> !EnumSet.allOf(InternalField.class).contains(field))`, OR
- compute `allowed = FieldFactory.getAllFieldsWithOutInternal()` and keep only `allowed::contains`.
Also consider avoiding double `entry.getField(f)` lookups by using `entry.getField(f).filter(value -> !value.isBlank()).isPresent()`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
|
||
| private void initializeFromAndToComboBox() { | ||
| fromFieldComboBox.getItems().setAll(viewModel.getAllFields()); | ||
| fromFieldComboBox.getItems().setAll(viewModel.getSetFieldsOnly()); |
There was a problem hiding this comment.
Group all from and to together - not this mixture...
| canAppend = Bindings.and(overwriteFieldContentProperty(), fieldValidationStatus().validProperty()); | ||
| } | ||
|
|
||
| public Set<Field> getSetFieldsOnly() { |
There was a problem hiding this comment.
This method is now written down multiple times -- extract it to a helper class
package org/jabref/gui/edit/automaticfiededitor. Maybe FieldHelper and a static method.
✅ All tests passed ✅🏷️ Commit: 089893d Learn more about TestLens at testlens.app. |
Refined the Automatic Field Editor to filter field lists based on populated data in selected entries.
|
Hi @koppor , I have addressed all the feedback! |
| private final List<BibEntry> selectedEntries; | ||
| private final BibDatabase database; | ||
| private final StateManager stateManager; | ||
| private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer(); | ||
| @FXML | ||
| private Button moveContentButton; | ||
|
|
||
| @FXML | ||
| private Button swapContentButton; | ||
|
|
||
| @FXML | ||
| private ComboBox<Field> fromFieldComboBox; | ||
| @FXML | ||
| private ComboBox<Field> toFieldComboBox; | ||
|
|
||
| @FXML | ||
| private CheckBox overwriteFieldContentCheckBox; | ||
|
|
||
| private CopyOrMoveFieldContentTabViewModel viewModel; | ||
| private final List<BibEntry> selectedEntries; | ||
| private final BibDatabase database; | ||
| private final StateManager stateManager; |
| private final StateManager stateManager; | ||
|
|
||
| private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer(); | ||
|
|
* Refine Automatic Field Editor filtering logic - Updated Clear, Copy/Move, and Rename tabs to show only populated fields by default. - Added a "Show only set fields" checkbox to the Edit tab, enabled by default. - Improved default field selection in ViewModels to prevent empty/ghost placeholders. - Added localization for the new checkbox string. fixes #15066 * Refactor field filtering logic and update CHANGELOG.md * Update CHANGELOG with Automatic Field Editor refinement Refined the Automatic Field Editor to filter field lists based on populated data in selected entries. * Fix Checkstyle import order and PR formatting
|
Failed test - not sure, why. I will try re-merge. |
* upstream/main: Refine Automatic Field Editor filtering logic (fixes JabRef#15066) (JabRef#15094) Output URL to workflow Fix token Refine stats message Quick fix to reduce load on runners "Debug" output for assign-issue-action Streamline pr-comment.yml (and remove status: stale label) Feature provide insights citation fetcher (JabRef#15093) Automatic Grouping By Entry Type (JabRef#15081) Minor test fixes for arXiv (JabRef#15100) New Crowdin updates (JabRef#15101) recomment linked files handler (JabRef#15105) Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#15087) Streamline binaries (JabRef#15085)
Related issues and pull requests
Closes #15066
PR Description
This PR implements context-aware filtering within the Automatic Field Editor to streamline the user experience and ensure data integrity. I refined the field selection logic across all tabs so that dropdowns dynamically filter to show only populated fields based on the user's current entry selection, while maintaining the ability to toggle a full list in the "Edit" tab. These changes prevent users from interacting with irrelevant or empty fields, thereby eliminating confusing "ghost" placeholders and improving overall workflow efficiency.
Steps to test
Screenshots
Edit Content Tab (Checkbox and Default Selection):

Copy or Move Tab (Filtered 'From' list):

Clear Content and Rename Tabs (Always Filtered):


Required Verification Screenshot (Single entry with me as author Ashvin Kumar and issue number 15066 as title):

Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)