From 9b11edf566ea8b82a8f5043b685cb6a3c911e206 Mon Sep 17 00:00:00 2001 From: Priyanshu Gupta Date: Thu, 13 Feb 2025 03:42:05 +0530 Subject: [PATCH 01/30] Add fix options for integrity issues --- .../java/org/jabref/gui/frame/MainMenu.java | 2 +- .../gui/integrity/IntegrityCheckAction.java | 11 +- .../gui/integrity/IntegrityCheckDialog.fxml | 14 ++- .../gui/integrity/IntegrityCheckDialog.java | 106 +++++++++++++++++- .../IntegrityCheckDialogViewModel.java | 42 ++++++- src/main/resources/l10n/JabRef_en.properties | 10 ++ 6 files changed, 174 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/MainMenu.java b/src/main/java/org/jabref/gui/frame/MainMenu.java index a320bdd6348..a07028b2500 100644 --- a/src/main/java/org/jabref/gui/frame/MainMenu.java +++ b/src/main/java/org/jabref/gui/frame/MainMenu.java @@ -250,7 +250,7 @@ private void createMenu() { quality.getItems().addAll( factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(frame::getCurrentLibraryTab, dialogService, stateManager, preferences, entryTypesManager, taskExecutor)), factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, undoManager, preferences)), - factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, (UiTaskExecutor) taskExecutor, abbreviationRepository)), + factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, (UiTaskExecutor) taskExecutor, preferences, undoManager, abbreviationRepository)), factory.createMenuItem(StandardActions.CHECK_CONSISTENCY, new ConsistencyCheckAction(frame::getCurrentLibraryTab, dialogService, stateManager, preferences, entryTypesManager, (UiTaskExecutor) taskExecutor)), factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new CleanupAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, taskExecutor, undoManager)), diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java index 506dee530fb..008a706d678 100644 --- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java +++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java @@ -4,6 +4,8 @@ import java.util.List; import java.util.function.Supplier; +import javax.swing.undo.UndoManager; + import javafx.collections.ObservableList; import javafx.concurrent.Task; @@ -17,6 +19,7 @@ import org.jabref.logic.integrity.IntegrityMessage; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.preferences.CliPreferences; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; @@ -29,6 +32,8 @@ public class IntegrityCheckAction extends SimpleCommand { private final Supplier tabSupplier; private final GuiPreferences preferences; private final StateManager stateManager; + private final CliPreferences cliPreferences; + private final UndoManager undoManager; private final JournalAbbreviationRepository abbreviationRepository; public IntegrityCheckAction(Supplier tabSupplier, @@ -36,12 +41,16 @@ public IntegrityCheckAction(Supplier tabSupplier, DialogService dialogService, StateManager stateManager, UiTaskExecutor taskExecutor, + CliPreferences cliPreferences, + UndoManager undoManager, JournalAbbreviationRepository abbreviationRepository) { this.tabSupplier = tabSupplier; this.stateManager = stateManager; this.taskExecutor = taskExecutor; this.preferences = preferences; this.dialogService = dialogService; + this.cliPreferences = cliPreferences; + this.undoManager = undoManager; this.abbreviationRepository = abbreviationRepository; this.executable.bind(needsDatabase(this.stateManager)); } @@ -78,7 +87,7 @@ protected List call() { if (messages.isEmpty()) { dialogService.notify(Localization.lang("No problems found.")); } else { - dialogService.showCustomDialogAndWait(new IntegrityCheckDialog(messages, tabSupplier.get())); + dialogService.showCustomDialogAndWait(new IntegrityCheckDialog(messages, tabSupplier, dialogService, stateManager, taskExecutor, cliPreferences, undoManager)); } }); task.setOnFailed(event -> dialogService.showErrorDialogAndWait("Integrity check failed.", task.getException())); diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.fxml b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.fxml index 7666785b6ad..1691749e670 100644 --- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.fxml +++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.fxml @@ -8,15 +8,18 @@ + + - + - + + @@ -26,7 +29,12 @@ -