Skip to content

Conversation

@alexsukhin
Copy link
Contributor

@alexsukhin alexsukhin commented Sep 10, 2025

Closes #13819

This PR adds three tabs to the "Clean up entries" dialog: Single-field, File-related, and Multi-field, representing different types of formatters.

Pressing Apply applies the selected actions of the currently active tab, and Close closes the dialog.

Steps to test

  1. Launch JabRef
  2. Create a new example library
  3. Select an entry
  4. Go to Quality → Clean up entries and select your desired formatters
  5. Apply the formatters or Close the dialog
image image image

Mandatory checks

@alexsukhin alexsukhin marked this pull request as draft September 10, 2025 23:25
- Removed trivial comments
- Renamed PDF-related variables
- Updated methods to return Optional
- Used Optional property for FieldFormatterCleanups
- Removed trivial comments
- Fixed CHANGELOG.md
@alexsukhin alexsukhin force-pushed the 13819-add-dialog-tabs branch from e8093f7 to 14fde53 Compare September 11, 2025 01:17
Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

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

First impression after skimming through your changes: looks good, right track. Just set your PR to rfr as soon as you think we should review it.

Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

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

Hi, thanks for your PR,
the code itself looks fine to me.
However, I think with the refactoring to the tabbed dialog, there is now a logical gap:
You use the strategy pattern to configure the preferences to use in the calling CleanupAction and the currently selected tab as part of the configuration, what action should be called: single / multi ... I dont think that this is a good and intuitive ui pattern.

We discussed this shortly on JabCon. We think the solution would be the following ():

  • Dismiss returning configuration from the dialog, and pull the logic from the action into a viewmodel of the cleanupDialog.
  • Move the ok/cleanup button in the ui inside each tab
  • Leave a close/cancel button at the bottom of the dialog.

Hopefully this will relax the complexity of the code and wont mean too much refactoring.
(@koppor @Siedlerchr wdyt?)

Comment on lines 38 to 41
if (button.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();
CleanupPanel panel = (CleanupPanel) selectedTab.getContent();
return panel.getCleanupPreferences();
Copy link
Member

Choose a reason for hiding this comment

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

This is weird for this dialog.

tsantalis added a commit to tsantalis/RefactoringMiner that referenced this pull request Sep 12, 2025
Split Class	org.jabref.gui.cleanup.CleanupPresetPanel split to [org.jabref.gui.cleanup.CleanupFileRelatedPanel, org.jabref.gui.cleanup.CleanupMultiFieldPanel]
tsantalis added a commit to tsantalis/RefactoringMiner that referenced this pull request Sep 12, 2025
@alexsukhin
Copy link
Contributor Author

alexsukhin commented Sep 12, 2025

Hi, thank you for the review! I understand that moving the cleanup logic into a ViewModel per tab will simplify the UI.

Just to confirm, is the enum refactor okay? I will return a CleanupPreferences from the ViewModel containing the preferences from the currently selected tab, and in CleanupAction I will update the initial preferences by replacing the category with the preferences returned from the tab.

I will also move the Apply button into each tab and leave a global Close button at the bottom.

@calixtus
Copy link
Member

About View and ViewModel: Every piece of logic should go into the ViewModel. You have a button on each tab, calling a different function in the viewmodel. So there should be no need for the enum anymore. See https://devdocs.jabref.org/code-howtos/javafx.html#architecture-model---view---controller---viewmodel-mvcvm

@alexsukhin alexsukhin marked this pull request as draft September 12, 2025 22:07
alexsukhin and others added 5 commits September 14, 2025 03:24
- Create new ViewModel, pull logic from Action and SingleAction into ViewModel
- Move Apply button to each tab
- Remove categories from ENUM and keep enums of all jobs in each respective tab to be used for cleanup
* Fix non record comments by carl

# Conflicts:
#	jabgui/src/main/java/org/jabref/gui/edit/automaticfiededitor/MoveFieldValueAction.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/cell/sidebuttons/ToggleMergeUnmergeButton.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/CommentMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/FieldMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/FileMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/GroupMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/KeywordMerger.java
#	jablib/src/main/java/org/jabref/logic/layout/format/HTMLChars.java
#	jablib/src/main/java/org/jabref/model/entry/identifier/ArXivIdentifier.java
#	jablib/src/main/java/org/jabref/model/entry/identifier/EprintIdentifier.java

* Add file exceptions

* Remove shebang line

* Remove shebang line

* Remove shebang line

* Expand variables & rename class

---------

Co-authored-by: Oliver Kopp <[email protected]>
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Oct 1, 2025
@trag-bot
Copy link

trag-bot bot commented Oct 2, 2025

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

@alexsukhin
Copy link
Contributor Author

Hi, this PR is ready for review :)

@calixtus
Copy link
Member

calixtus commented Oct 9, 2025

We will look into it asap, but it could take a few days, as we are currently all very busy with our day jobs. Please excuse our tight schedule.

@calixtus calixtus added component: ui component: cleanup-ops status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Oct 9, 2025
@koppor
Copy link
Member

koppor commented Nov 5, 2025

I think RefactoringMiner is needed for review. Reason: Need to check which code is new and which code was just moved.

@koppor koppor mentioned this pull request Nov 6, 2025
1 task
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Two micro comment; one minor comment, then it should be good to go.

Comment on lines 153 to 155
if (tabSupplier != null) {
tabSupplier.get().markBaseChanged();
}
Copy link
Member

Choose a reason for hiding this comment

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

This logic is different from the old code

It is strange that tabSupplier is asked for null.

  1. When can it be null?
  2. Shouldn't just simply be checked for modifiedEntriesCount being greater than 0 - as in the old code?
Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, just to clarify: the tabSupplier != null check was added for the single-action case, where tabSupplier is null. I also added the modifiedEntriesCount > 0 condition to ensure that the base is only marked as changed when an entry is actually modified.

Copy link
Member

Choose a reason for hiding this comment

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

There is a code commetn for that, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi no, not yet I will add a comment ASAP!

alexsukhin and others added 3 commits November 9, 2025 20:40
- Remove redundant comments following self-explanatory code
- Add modifiedEntriesCount > 0 condition
- Use "entry(s)" localization form for clean up message
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

OK, let's get this in. In case there are issues, we can fix later 😅

@koppor koppor enabled auto-merge November 11, 2025 17:38
@koppor koppor added this pull request to the merge queue Nov 11, 2025
Merged via the queue into JabRef:main with commit c0642a7 Nov 11, 2025
48 checks passed
@github-actions github-actions bot mentioned this pull request Nov 11, 2025
merlinymy pushed a commit to merlinymy/jabref that referenced this pull request Nov 19, 2025
* Add cleanup dialog tabs with individual tab preferences

* Fixed indentation and added commenting

* Fix Trag-bot review issues

- Removed trivial comments
- Renamed PDF-related variables
- Updated methods to return Optional
- Used Optional property for FieldFormatterCleanups

* Fix Trag-bot review issues

- Removed trivial comments
- Fixed CHANGELOG.md

* Fix Trag-bot review issues

- Removed trivial comments
- Improved Optional checks
- Perform null check for other parameters

* Avoid nested Optionals, returning Optional<CleanupPreferences> directly

* Refactor CleanupPreferences by keeping one assertion per test

* Converted tests to assertEquals

* Maintain consistent naming conventions

* Returns CleanupPreferences directly since value is always present

* Initial review refactor draft
- Create new ViewModel, pull logic from Action and SingleAction into ViewModel
- Move Apply button to each tab
- Remove categories from ENUM and keep enums of all jobs in each respective tab to be used for cleanup

* fix import error!

* Reformat codebase (more carefully) (JabRef#13885)

* Fix non record comments by carl

# Conflicts:
#	jabgui/src/main/java/org/jabref/gui/edit/automaticfiededitor/MoveFieldValueAction.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/cell/sidebuttons/ToggleMergeUnmergeButton.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/CommentMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/FieldMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/FileMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/GroupMerger.java
#	jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/fieldsmerger/KeywordMerger.java
#	jablib/src/main/java/org/jabref/logic/layout/format/HTMLChars.java
#	jablib/src/main/java/org/jabref/model/entry/identifier/ArXivIdentifier.java
#	jablib/src/main/java/org/jabref/model/entry/identifier/EprintIdentifier.java

* Add file exceptions

* Remove shebang line

* Remove shebang line

* Remove shebang line

* Expand variables & rename class

---------

Co-authored-by: Oliver Kopp <[email protected]>

* fix import error & merge

* Apply OpenRewrite Cleanup

* Refactor Cleanup Tabs
- Moved cleanup panel logic into CleanupDialogViewModel for better separation of UI and logic
- Changed tabSupplier and taskExecutor from Optional to nullable parameters
- Moved updateWith logic into the record for cleaner preference updates.
- General design improvements: more maintainable.

* Fix getDisplayName method

* Fix formatting

* Trag-bot review and fix en properties

* fix indentation plssss

* format properly and change to observablelist

* fix formatting entriestoprocess (please)

* Updated names and changed optional dependencies back to nullable

* Refactored panels to use separate ViewModels
- Introduced ViewModels to encapsulate state and logic for panels.
- Replaced direct UI manipulation with bidirectional bindings.
- Ensures cleaner UI logic, easier maintenance

* Moved ALL_JOBS to respective ViewModels, small naming changes

* Replaced requireNotNull to @NotNull following JabRef#13957

* Address review feedback in CleanupDialogViewModel

- Remove redundant comments following self-explanatory code
- Add modifiedEntriesCount > 0 condition
- Use "entry(s)" localization form for clean up message

---------

Co-authored-by: Subhramit Basu <[email protected]>
Co-authored-by: Oliver Kopp <[email protected]>
Co-authored-by: Christoph <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: cleanup-ops component: ui status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup entries

5 participants