Skip to content

Conversation

Akanksha928
Copy link
Contributor

Closes #13780

This PR introduces a dedicated "Clear content" tab in the Automatic Field Editor:

  • Added a new "Clear content" tab with a dropdown to select the field to clear
  • Added a "Show only set fields" checkbox to filter the dropdown to fields actually filled in selected entries
  • Removed the "Clear field content" button from the "Edit content" tab (moved functionality to the new tab)
  • Clearing supports Undo/Redo via NamedCompound + UndoableFieldChange
  • Added i18n keys for all new UI text
image

Steps to test

  1. Open or create a library with a few entries (fill in some fields like author, journal).
  2. Select one or more entries.
  3. Open Edit → Automatic field editor.
  4. Switch to the new Clear content tab.
  5. Toggle the "Show only set fields" checkbox: the dropdown should shrink to only the fields currently filled.
  6. Select a field (e.g., author) and click Clear field content: the field value should be removed from all selected entries.
  7. Press Ctrl+Z: the cleared field(s) should be restored.

screenshot of Clear content tab

Mandatory checks

Field chosen = fieldCombo.getValue(); // keep ComboBox<Field>
if (chosen != null) {
viewModel.clearField(chosen); // VM builds/publishes the undo compound
System.out.println("Cleared field: " + chosen.getName());
Copy link
Member

Choose a reason for hiding this comment

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

No System.out and remove the comments


List<BibEntry> selected = stateManager.getSelectedEntries();
for (BibEntry entry : selected) {
// clearField returns Optional<FieldChange>
Copy link
Member

Choose a reason for hiding this comment

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

remove comments

List<BibEntry> selected = stateManager.getSelectedEntries();
Set<Field> setFields = new LinkedHashSet<>();

for (BibEntry entry : selected) {
Copy link
Member

Choose a reason for hiding this comment

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

can be refactored into a stream

private final ClearContentViewModel viewModel;

public ClearContentTabView(StateManager stateManager) {
super();
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reasony why you did not creae an fxml? I guess you used AI..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I initially used AI to generate the layout in Java so I could focus on getting the logic working first but forgot to move it into a proper FXML file. I've made the changes now.

@Siedlerchr Siedlerchr added the status: changes-required Pull requests that are not yet complete label Sep 8, 2025
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.

.

@calixtus
Copy link
Member

calixtus commented Sep 8, 2025

Sorry, misunderstood PR. Nevermind.

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Oct 6, 2025
@Siedlerchr Siedlerchr requested a review from calixtus October 6, 2025 20:05
import org.jabref.model.entry.field.FieldFactory;

public class ClearContentViewModel {
public static final int TAB_INDEX = 2;
Copy link
Member

Choose a reason for hiding this comment

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

TAB_INDEX constant is horrible, but is actually consistent with the current design of the dialog. Neccessary for the fancy infotext about affected files after applying the change. Should be refactored in the future, but for now, it can just stay.

calixtus
calixtus previously approved these changes Oct 6, 2025
@calixtus calixtus enabled auto-merge October 6, 2025 21:59
@calixtus calixtus requested a review from Siedlerchr October 6, 2025 22:00
@JabRef JabRef deleted a comment from jabref-machine Oct 7, 2025
@JabRef JabRef deleted a comment from jabref-machine Oct 7, 2025
@JabRef JabRef deleted a comment from jabref-machine Oct 7, 2025
@jabref-machine
Copy link
Collaborator

You did not assign yourself to the issue. Thus, it looks like you skipped reading our CONTRIBUTING.md, which explains exactly how to participate. No worries, it happens to the best of us.

Give it a read, and you’ll discover the ancient wisdom of assigning issues to yourself. Trust me, it’s worth it. 🚀

@calixtus calixtus added this pull request to the merge queue Oct 7, 2025
Merged via the queue into JabRef:main with commit 0a63038 Oct 7, 2025
82 of 85 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic field editor: Checkbox: Show only set fields
4 participants