diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 5a4c0476b97..ce6cf9092fa 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -755,7 +755,7 @@ private MenuBar createMenu() { quality.getItems().addAll( factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(this, dialogService, stateManager)), - factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager)), + factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(this, dialogService, stateManager)), factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(this, stateManager, Globals.TASK_EXECUTOR)), factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new OldDatabaseCommandWrapper(Actions.CLEANUP, this, stateManager)), diff --git a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java index 1aec1973d49..b55c525dc13 100644 --- a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java +++ b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java @@ -68,7 +68,7 @@ public static ContextMenu create(BibEntryTableViewModel entry, KeyBindingReposit contextMenu.getItems().add(new ChangeEntryTypeMenu().getChangeEntryTypeMenu(entry.getEntry(), panel.getBibDatabaseContext(), panel.getUndoManager())); contextMenu.getItems().add(factory.createMenuItem(StandardActions.MERGE_WITH_FETCHED_ENTRY, new MergeWithFetchedEntryAction(panel, dialogService, stateManager))); contextMenu.getItems().add(factory.createMenuItem(StandardActions.ATTACH_FILE, new AttachFileAction(panel, dialogService, stateManager, preferencesService))); - contextMenu.getItems().add(factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager))); + contextMenu.getItems().add(factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(panel.frame(), dialogService, stateManager))); return contextMenu; } diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java index a31eb06fbcc..7ccc29e2515 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java @@ -6,6 +6,7 @@ import org.jabref.Globals; import org.jabref.gui.DialogService; +import org.jabref.gui.JabRefFrame; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; @@ -18,10 +19,12 @@ public class MergeEntriesAction extends SimpleCommand { + private final JabRefFrame frame; private final DialogService dialogService; private final StateManager stateManager; - public MergeEntriesAction(DialogService dialogService, StateManager stateManager) { + public MergeEntriesAction(JabRefFrame frame, DialogService dialogService, StateManager stateManager) { + this.frame = frame; this.dialogService = dialogService; this.stateManager = stateManager; @@ -53,9 +56,10 @@ public void execute() { dlg.setTitle(Localization.lang("Merge entries")); Optional mergedEntry = dlg.showAndWait(); if (mergedEntry.isPresent()) { - // FixMe: BibDatabase::insertEntry does not contain logic to mark the BasePanel as changed and to mark - // entries with a timestamp, only BasePanel::insertEntry does. - databaseContext.getDatabase().insertEntry(mergedEntry.get()); + // ToDo: BibDatabase::insertEntry does not contain logic to mark the BasePanel as changed and to mark + // entries with a timestamp, only BasePanel::insertEntry does. Workaround for the moment is to get the + // BasePanel from the constructor injected JabRefFrame. Should be refactored and extracted! + frame.getCurrentBasePanel().insertEntry(mergedEntry.get()); // Create a new entry and add it to the undo stack // Remove the other two entries and add them to the undo stack (which is not working...)