From 9fbac6abc188470f8069a419d200e30412dc52ba Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 26 Dec 2023 10:26:39 +0100 Subject: [PATCH 01/18] Removed code duplication --- .../java/org/jabref/gui/maintable/MainTableDataModel.java | 8 ++++---- .../org/jabref/gui/preferences/ShowPreferencesAction.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java b/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java index bc91167bb88..f80a1d84baa 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java @@ -29,7 +29,7 @@ public class MainTableDataModel { private final FilteredList entriesFiltered; private final SortedList entriesFilteredAndSorted; - private final ObjectProperty fieldValueFormatter; + private final ObjectProperty fieldValueFormatter = new SimpleObjectProperty<>(); private final GroupsPreferences groupsPreferences; private final NameDisplayPreferences nameDisplayPreferences; private final BibDatabaseContext bibDatabaseContext; @@ -38,8 +38,8 @@ public MainTableDataModel(BibDatabaseContext context, PreferencesService prefere this.groupsPreferences = preferencesService.getGroupsPreferences(); this.nameDisplayPreferences = preferencesService.getNameDisplayPreferences(); this.bibDatabaseContext = context; - this.fieldValueFormatter = new SimpleObjectProperty<>( - new MainTableFieldValueFormatter(nameDisplayPreferences, bibDatabaseContext)); + + resetFieldFormatter(); ObservableList allEntries = BindingsHelper.forUI(context.getDatabase().getEntries()); ObservableList entriesViewModel = EasyBind.mapBacked(allEntries, entry -> @@ -96,7 +96,7 @@ public SortedList getEntriesFilteredAndSorted() { return entriesFilteredAndSorted; } - public void refresh() { + public void resetFieldFormatter() { this.fieldValueFormatter.setValue(new MainTableFieldValueFormatter(nameDisplayPreferences, bibDatabaseContext)); } } diff --git a/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java b/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java index 08eec1e610c..510632521f7 100644 --- a/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java +++ b/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java @@ -28,6 +28,6 @@ public void execute() { // Refresh frame and tables jabRefFrame.getGlobalSearchBar().updateHintVisibility(); jabRefFrame.setupAllTables(); - jabRefFrame.getLibraryTabs().forEach(panel -> panel.getMainTable().getTableModel().refresh()); + jabRefFrame.getLibraryTabs().forEach(panel -> panel.getMainTable().getTableModel().resetFieldFormatter()); } } From c6e537313a39b7318ff60a0bd0a4df8392d40216 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:31:52 +0100 Subject: [PATCH 02/18] Moved LibraryTab to its own package --- src/main/java/org/jabref/gui/EntryTypeView.java | 1 + src/main/java/org/jabref/gui/EntryTypeViewModel.java | 1 + src/main/java/org/jabref/gui/JabRefFrame.java | 5 +++-- src/main/java/org/jabref/gui/JabRefGUI.java | 1 + .../java/org/jabref/gui/LibraryTabContainer.java | 1 + .../java/org/jabref/gui/UpdateTimestampListener.java | 4 ++-- .../org/jabref/gui/WaitForSaveFinishedDialog.java | 1 + .../jabref/gui/autosaveandbackup/BackupManager.java | 2 +- .../org/jabref/gui/collab/DatabaseChangeMonitor.java | 2 +- .../org/jabref/gui/dialogs/AutosaveUiManager.java | 2 +- .../gui/duplicationFinder/DuplicateSearch.java | 2 +- .../java/org/jabref/gui/edit/ReplaceStringView.java | 2 +- .../org/jabref/gui/edit/ReplaceStringViewModel.java | 2 +- .../automaticfiededitor/NotificationPaneAdapter.java | 2 +- .../java/org/jabref/gui/entryeditor/EntryEditor.java | 2 +- .../citationrelationtab/CitationRelationsTab.java | 2 +- .../java/org/jabref/gui/exporter/ExportCommand.java | 2 +- .../java/org/jabref/gui/exporter/SaveAllAction.java | 2 +- .../org/jabref/gui/exporter/SaveDatabaseAction.java | 2 +- .../gui/importer/GenerateEntryFromIdAction.java | 2 +- .../gui/importer/GenerateEntryFromIdDialog.java | 2 +- .../java/org/jabref/gui/importer/ImportCommand.java | 2 +- .../actions/CheckForNewEntryTypesAction.java | 2 +- .../gui/importer/actions/GUIPostOpenAction.java | 2 +- .../actions/MergeReviewIntoCommentAction.java | 2 +- .../gui/importer/actions/OpenDatabaseAction.java | 2 +- .../jabref/gui/integrity/IntegrityCheckDialog.java | 2 +- .../org/jabref/gui/{ => library}/LibraryTab.java | 12 +++++++++--- .../org/jabref/gui/linkedfile/AttachFileAction.java | 2 +- .../java/org/jabref/gui/maintable/MainTable.java | 2 +- .../org/jabref/gui/maintable/RightClickMenu.java | 2 +- .../org/jabref/gui/openoffice/OpenOfficePanel.java | 2 +- .../gui/search/RebuildFulltextSearchIndexAction.java | 2 +- .../shared/SharedDatabaseLoginDialogViewModel.java | 2 +- .../jabref/gui/shared/SharedDatabaseUIManager.java | 2 +- .../java/org/jabref/gui/undo/UndoRedoAction.java | 2 +- .../logic/pdf/search/indexing/DocumentReader.java | 2 +- .../jabref/logic/pdf/search/indexing/PdfIndexer.java | 2 +- .../logic/pdf/search/retrieval/PdfSearcher.java | 2 +- .../jabref/model/database/BibDatabaseContext.java | 2 +- .../BackupManagerDiscardedTest.java | 2 +- .../gui/autosaveandbackup/BackupManagerTest.java | 2 +- .../jabref/gui/edit/ReplaceStringViewModelTest.java | 2 +- .../jabref/gui/exporter/SaveDatabaseActionTest.java | 2 +- .../org/jabref/gui/importer/NewEntryActionTest.java | 2 +- 45 files changed, 56 insertions(+), 44 deletions(-) rename src/main/java/org/jabref/gui/{ => library}/LibraryTab.java (98%) diff --git a/src/main/java/org/jabref/gui/EntryTypeView.java b/src/main/java/org/jabref/gui/EntryTypeView.java index 238d80d7d17..2c389771015 100644 --- a/src/main/java/org/jabref/gui/EntryTypeView.java +++ b/src/main/java/org/jabref/gui/EntryTypeView.java @@ -17,6 +17,7 @@ import javafx.scene.layout.FlowPane; import javafx.stage.Screen; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.IconValidationDecorator; diff --git a/src/main/java/org/jabref/gui/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/EntryTypeViewModel.java index a197348997a..2cbc5908d07 100644 --- a/src/main/java/org/jabref/gui/EntryTypeViewModel.java +++ b/src/main/java/org/jabref/gui/EntryTypeViewModel.java @@ -16,6 +16,7 @@ import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.importer.NewEntryAction; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.importer.FetcherClientException; import org.jabref.logic.importer.FetcherException; diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 3f0f95a6955..2c7afa222ec 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -47,6 +47,7 @@ import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.libraryproperties.LibraryPropertiesAction; import org.jabref.gui.menus.FileHistoryMenu; import org.jabref.gui.push.PushToApplicationCommand; @@ -593,7 +594,7 @@ public void init() { openDatabaseList = EasyBind.map(filteredTabs, tab -> ((LibraryTab) tab).getBibDatabaseContext()); EasyBind.bindContent(stateManager.getOpenDatabases(), openDatabaseList); - // the binding for stateManager.activeDatabaseProperty() is at org.jabref.gui.LibraryTab.onDatabaseLoadingSucceed + // the binding for stateManager.activeDatabaseProperty() is at org.jabref.gui.library.LibraryTab.onDatabaseLoadingSucceed // Subscribe to the search EasyBind.subscribe(stateManager.activeSearchQueryProperty(), @@ -735,7 +736,7 @@ public void addTab(LibraryTab libraryTab, boolean raisePanel) { /** * Opens a new tab with existing data. - * Asynchronous loading is done at {@link org.jabref.gui.LibraryTab#createLibraryTab(BackgroundTask, Path, DialogService, PreferencesService, StateManager, JabRefFrame, FileUpdateMonitor, BibEntryTypesManager, CountingUndoManager)}. + * Asynchronous loading is done at {@link LibraryTab#createLibraryTab(BackgroundTask, Path, DialogService, PreferencesService, StateManager, JabRefFrame, FileUpdateMonitor, BibEntryTypesManager, CountingUndoManager)}. */ public void addTab(BibDatabaseContext databaseContext, boolean raisePanel) { Objects.requireNonNull(databaseContext); diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 9a402703619..95208933306 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -18,6 +18,7 @@ import org.jabref.gui.importer.ParserResultWarningDialog; import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.TextInputKeyBindings; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; import org.jabref.logic.net.ProxyRegisterer; diff --git a/src/main/java/org/jabref/gui/LibraryTabContainer.java b/src/main/java/org/jabref/gui/LibraryTabContainer.java index 4d3c504d503..f895f75546d 100644 --- a/src/main/java/org/jabref/gui/LibraryTabContainer.java +++ b/src/main/java/org/jabref/gui/LibraryTabContainer.java @@ -2,6 +2,7 @@ import java.util.List; +import org.jabref.gui.library.LibraryTab; import org.jabref.model.database.BibDatabaseContext; public interface LibraryTabContainer { diff --git a/src/main/java/org/jabref/gui/UpdateTimestampListener.java b/src/main/java/org/jabref/gui/UpdateTimestampListener.java index 2ccc4a72d3c..a4fa13f7e62 100644 --- a/src/main/java/org/jabref/gui/UpdateTimestampListener.java +++ b/src/main/java/org/jabref/gui/UpdateTimestampListener.java @@ -10,10 +10,10 @@ /** * Updates the timestamp of changed entries if the feature is enabled */ -class UpdateTimestampListener { +public class UpdateTimestampListener { private final PreferencesService preferencesService; - UpdateTimestampListener(PreferencesService preferencesService) { + public UpdateTimestampListener(PreferencesService preferencesService) { this.preferencesService = preferencesService; } diff --git a/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java b/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java index 43f784669de..637ce73b949 100644 --- a/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java +++ b/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java @@ -4,6 +4,7 @@ import javafx.concurrent.Task; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.l10n.Localization; /** diff --git a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java index 1b9017f192f..a4732494269 100644 --- a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java @@ -21,7 +21,7 @@ import javafx.scene.control.TableColumn; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.logic.bibtex.InvalidFieldValueException; diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java index fed43800e19..5429bd4e3aa 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java @@ -7,8 +7,8 @@ import javafx.util.Duration; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java b/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java index ace8e2a18ad..93469dc82ac 100644 --- a/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java +++ b/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java @@ -1,8 +1,8 @@ package org.jabref.gui.dialogs; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.exporter.SaveDatabaseAction; +import org.jabref.gui.library.LibraryTab; import org.jabref.model.database.event.AutosaveEvent; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java index 0beda09fdf5..b0578f2ee55 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java @@ -18,11 +18,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefExecutorService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.duplicationFinder.DuplicateResolverDialog.DuplicateResolverResult; import org.jabref.gui.duplicationFinder.DuplicateResolverDialog.DuplicateResolverType; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableInsertEntries; import org.jabref.gui.undo.UndoableRemoveEntries; diff --git a/src/main/java/org/jabref/gui/edit/ReplaceStringView.java b/src/main/java/org/jabref/gui/edit/ReplaceStringView.java index a931406c99c..9eb70981e27 100644 --- a/src/main/java/org/jabref/gui/edit/ReplaceStringView.java +++ b/src/main/java/org/jabref/gui/edit/ReplaceStringView.java @@ -6,7 +6,7 @@ import javafx.scene.control.RadioButton; import javafx.scene.control.TextField; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.IconValidationDecorator; diff --git a/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java b/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java index 04db4bf9147..0787c418f8c 100644 --- a/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java +++ b/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java @@ -9,7 +9,7 @@ import javafx.beans.property.StringProperty; import org.jabref.gui.AbstractViewModel; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java b/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java index 4fc8b9d8b63..0993c00bdba 100644 --- a/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java +++ b/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java @@ -5,8 +5,8 @@ import javafx.scene.Node; import javafx.util.Duration; -import org.jabref.gui.LibraryTab; import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.library.LibraryTab; public class NotificationPaneAdapter extends LibraryTab.DatabaseNotification { diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 7ee6f1b6968..68b2044b40a 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -27,7 +27,6 @@ import javafx.scene.layout.BorderPane; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.citationkeypattern.GenerateCitationKeySingleAction; import org.jabref.gui.cleanup.CleanupSingleAction; @@ -39,6 +38,7 @@ import org.jabref.gui.importer.GrobidOptInDialogHelper; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.menus.ChangeEntryTypeMenu; import org.jabref.gui.mergeentries.FetchAndMergeEntry; import org.jabref.gui.theme.ThemeManager; diff --git a/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java b/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java index 01e2249d1b0..69a8f49eb63 100644 --- a/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java @@ -26,7 +26,6 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.entryeditor.EntryEditorPreferences; import org.jabref.gui.entryeditor.EntryEditorTab; @@ -34,6 +33,7 @@ import org.jabref.gui.entryeditor.citationrelationtab.semanticscholar.SemanticScholarFetcher; import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.NoSelectionModel; import org.jabref.gui.util.ViewModelListCellFactory; diff --git a/src/main/java/org/jabref/gui/exporter/ExportCommand.java b/src/main/java/org/jabref/gui/exporter/ExportCommand.java index 02e034ae763..37e0a405282 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportCommand.java +++ b/src/main/java/org/jabref/gui/exporter/ExportCommand.java @@ -12,12 +12,12 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.gui.util.FileFilterConverter; diff --git a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java index eb86c5df658..57b6e58085d 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java @@ -3,8 +3,8 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.l10n.Localization; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java index 87cb097b734..07760a7bf79 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java @@ -19,9 +19,9 @@ import javafx.scene.text.Text; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.autosaveandbackup.AutosaveManager; import org.jabref.gui.autosaveandbackup.BackupManager; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java index d6e36a5d1eb..0a78edad20b 100644 --- a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java +++ b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java @@ -3,10 +3,10 @@ import java.util.Optional; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.externalfiles.ImportHandler; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.importer.CompositeIdFetcher; diff --git a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java index e1a1c7cfc26..44467fb06aa 100644 --- a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java +++ b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java @@ -6,9 +6,9 @@ import javafx.scene.control.TextField; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; import org.jabref.model.util.FileUpdateMonitor; diff --git a/src/main/java/org/jabref/gui/importer/ImportCommand.java b/src/main/java/org/jabref/gui/importer/ImportCommand.java index fd74e7a5199..6908107f7f7 100644 --- a/src/main/java/org/jabref/gui/importer/ImportCommand.java +++ b/src/main/java/org/jabref/gui/importer/ImportCommand.java @@ -13,9 +13,9 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.gui.util.FileDialogConfiguration; diff --git a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java index c1e0208a65e..545f893719d 100644 --- a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java @@ -5,8 +5,8 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; -import org.jabref.gui.LibraryTab; import org.jabref.gui.importer.ImportCustomEntryTypesDialog; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.importer.ParserResult; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntryType; diff --git a/src/main/java/org/jabref/gui/importer/actions/GUIPostOpenAction.java b/src/main/java/org/jabref/gui/importer/actions/GUIPostOpenAction.java index cc943956861..d361aaa68f5 100644 --- a/src/main/java/org/jabref/gui/importer/actions/GUIPostOpenAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/GUIPostOpenAction.java @@ -1,6 +1,6 @@ package org.jabref.gui.importer.actions; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.importer.ParserResult; /** diff --git a/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java b/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java index a8bb0a453f1..39f5206e1c5 100644 --- a/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentAction.java @@ -2,7 +2,7 @@ import java.util.List; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.importer.ParserResult; import org.jabref.migrations.MergeReviewIntoCommentMigration; import org.jabref.model.entry.BibEntry; diff --git a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java index 4e2854ba764..1b10e99b9ea 100644 --- a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java @@ -15,12 +15,12 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.Telemetry; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.autosaveandbackup.BackupManager; import org.jabref.gui.dialogs.BackupUIManager; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.shared.SharedDatabaseUIManager; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java index 368951a4bc3..e11c4c3736a 100644 --- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java +++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java @@ -13,7 +13,7 @@ import javafx.scene.input.MouseButton; import javafx.stage.Modality; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.theme.ThemeManager; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ValueTableCellFactory; diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/library/LibraryTab.java similarity index 98% rename from src/main/java/org/jabref/gui/LibraryTab.java rename to src/main/java/org/jabref/gui/library/LibraryTab.java index 137a9548678..18ea6d8ce24 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/library/LibraryTab.java @@ -1,4 +1,4 @@ -package org.jabref.gui; +package org.jabref.gui.library; import java.io.IOException; import java.nio.file.Path; @@ -25,6 +25,12 @@ import javafx.scene.layout.BorderPane; import javafx.util.Duration; +import org.jabref.gui.BasePanelMode; +import org.jabref.gui.DialogService; +import org.jabref.gui.Globals; +import org.jabref.gui.JabRefFrame; +import org.jabref.gui.StateManager; +import org.jabref.gui.UpdateTimestampListener; import org.jabref.gui.autocompleter.AutoCompletePreferences; import org.jabref.gui.autocompleter.PersonNameSuggestionProvider; import org.jabref.gui.autocompleter.SuggestionProviders; @@ -124,7 +130,7 @@ public class LibraryTab extends Tab { private final IndexingTaskManager indexingTaskManager; private final TaskExecutor taskExecutor; - public LibraryTab(BibDatabaseContext bibDatabaseContext, + private LibraryTab(BibDatabaseContext bibDatabaseContext, JabRefFrame frame, DialogService dialogService, PreferencesService preferencesService, @@ -253,7 +259,7 @@ public void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { // At that point, the library tab is given a temporary bibDatabaseContext with no entries. // This line is necessary because, while there is already a binding that updates the active database when a new tab is added, // it doesn't handle the case when a library is loaded asynchronously. - // See org.jabref.gui.LibraryTab.createLibraryTab for the asynchronous loading. + // See org.jabref.gui.library.LibraryTab.createLibraryTab for the asynchronous loading. stateManager.setActiveDatabase(bibDatabaseContextFromParserResult); } diff --git a/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java b/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java index 8dad9f0399c..1d906f7b7ba 100644 --- a/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java +++ b/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java @@ -4,11 +4,11 @@ import java.util.Optional; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.fieldeditors.LinkedFilesEditorViewModel; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 6ff70140fc7..27a0e401400 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -28,13 +28,13 @@ import org.jabref.gui.DialogService; import org.jabref.gui.DragAndDropDataFormats; import org.jabref.gui.Globals; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.StandardActions; import org.jabref.gui.edit.EditAction; import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.maintable.columns.LibraryColumn; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.gui.util.ControlHelper; diff --git a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java index 42686574b3e..7ead66ef02c 100644 --- a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java +++ b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java @@ -8,7 +8,6 @@ import org.jabref.gui.ClipBoardManager; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.SendAsKindleEmailAction; import org.jabref.gui.SendAsStandardEmailAction; import org.jabref.gui.StateManager; @@ -18,6 +17,7 @@ import org.jabref.gui.edit.EditAction; import org.jabref.gui.exporter.ExportToClipboardAction; import org.jabref.gui.keyboard.KeyBindingRepository; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.linkedfile.AttachFileAction; import org.jabref.gui.linkedfile.AttachFileFromURLAction; import org.jabref.gui.menus.ChangeEntryTypeMenu; diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 9e8b49e7d6a..b70fcb02e8d 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -28,7 +28,6 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefGUI; -import org.jabref.gui.LibraryTab; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionFactory; @@ -36,6 +35,7 @@ import org.jabref.gui.help.HelpAction; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.keyboard.KeyBindingRepository; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableKeyChange; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java b/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java index 4fb2a575ab6..2622a8994f1 100644 --- a/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java +++ b/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java @@ -3,9 +3,9 @@ import java.io.IOException; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java index 0e13f6bd2a4..0d4a486a373 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java @@ -25,10 +25,10 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.exporter.SaveDatabaseAction; import org.jabref.gui.help.HelpAction; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.gui.util.FileFilterConverter; import org.jabref.gui.util.TaskExecutor; diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java index 44d92e9c216..89562787c6b 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java @@ -13,10 +13,10 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.entryeditor.EntryEditor; import org.jabref.gui.exporter.SaveDatabaseAction; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.mergeentries.EntriesMergeResult; import org.jabref.gui.mergeentries.MergeEntriesDialog; import org.jabref.gui.undo.UndoableRemoveEntries; diff --git a/src/main/java/org/jabref/gui/undo/UndoRedoAction.java b/src/main/java/org/jabref/gui/undo/UndoRedoAction.java index 9515bda0654..161d10b96a8 100644 --- a/src/main/java/org/jabref/gui/undo/UndoRedoAction.java +++ b/src/main/java/org/jabref/gui/undo/UndoRedoAction.java @@ -5,11 +5,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.l10n.Localization; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java b/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java index e2e1c0f5b7e..9dbd1d67608 100644 --- a/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java +++ b/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java @@ -11,7 +11,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; diff --git a/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java b/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java index d10a6c0221a..8e02ea6de28 100644 --- a/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java +++ b/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java @@ -10,7 +10,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.util.StandardFileType; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; diff --git a/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java b/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java index 2fd7e54e5b0..51daa239d34 100644 --- a/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java +++ b/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Objects; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.pdf.search.EnglishStemAnalyzer; import org.jabref.model.pdf.search.PdfSearchResults; diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index 12d67a71a2f..85b46cbf7dd 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -9,7 +9,7 @@ import java.util.stream.Collectors; import org.jabref.architecture.AllowedToUseLogic; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.crawler.Crawler; import org.jabref.logic.crawler.StudyRepository; import org.jabref.logic.shared.DatabaseLocation; diff --git a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java index a1ee0b8031e..57a34bcd918 100644 --- a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java +++ b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java @@ -6,7 +6,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.exporter.AtomicFileWriter; import org.jabref.logic.exporter.BibDatabaseWriter; import org.jabref.logic.exporter.BibWriter; diff --git a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java index c1a0caf267d..33542102f63 100644 --- a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java +++ b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Optional; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.logic.util.BackupFileType; import org.jabref.logic.util.OS; import org.jabref.logic.util.io.BackupFileUtil; diff --git a/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java b/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java index 758e3a8241b..a7f884bd980 100644 --- a/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java +++ b/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java @@ -6,7 +6,7 @@ import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java index 5752fc7afa7..37fe4ab6a26 100644 --- a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java +++ b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java @@ -12,7 +12,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.bibtex.FieldPreferences; diff --git a/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java b/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java index 079bb6c1388..9dafea09acb 100644 --- a/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java +++ b/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java @@ -3,8 +3,8 @@ import org.jabref.gui.DialogService; import org.jabref.gui.EntryTypeView; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.types.EntryType; From 30ddc7ea115c4a771f8224fcdd11baca3b74813f Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:43:00 +0100 Subject: [PATCH 03/18] Moved call to LibraryTab::cleanup to libraryTab itself --- src/main/java/org/jabref/gui/JabRefFrame.java | 1 - src/main/java/org/jabref/gui/library/LibraryTab.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 2c7afa222ec..bf87940f39d 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -889,7 +889,6 @@ public void closeTab(LibraryTab libraryTab) { private void removeTab(LibraryTab libraryTab) { DefaultTaskExecutor.runInJavaFXThread(() -> { - libraryTab.cleanUp(); tabbedPane.getTabs().remove(libraryTab); }); } diff --git a/src/main/java/org/jabref/gui/library/LibraryTab.java b/src/main/java/org/jabref/gui/library/LibraryTab.java index 18ea6d8ce24..e172b0eac77 100644 --- a/src/main/java/org/jabref/gui/library/LibraryTab.java +++ b/src/main/java/org/jabref/gui/library/LibraryTab.java @@ -182,6 +182,8 @@ private LibraryTab(BibDatabaseContext bibDatabaseContext, stateManager.getOpenDatabases().addListener((ListChangeListener) c -> updateTabTitle(changedProperty.getValue())); }); + + setOnClosed(event -> cleanUp()); } private static void addChangedInformation(StringBuilder text, String fileName) { @@ -252,8 +254,6 @@ public void onDatabaseLoadingFailed(Exception ex) { } public void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { - cleanUp(); - if (this.getTabPane().getSelectionModel().selectedItemProperty().get().equals(this)) { // If you open an existing library, a library tab with a loading animation is added immediately. // At that point, the library tab is given a temporary bibDatabaseContext with no entries. @@ -718,7 +718,7 @@ private void saveDividerLocation(Number position) { /** * Perform necessary cleanup when this BasePanel is closed. */ - public void cleanUp() { + private void cleanUp() { changeMonitor.ifPresent(DatabaseChangeMonitor::unregister); AutosaveManager.shutdown(bibDatabaseContext); BackupManager.shutdown(bibDatabaseContext, preferencesService.getFilePreferences().getBackupDirectory(), preferencesService.getFilePreferences().shouldCreateBackup()); From eab3616ec218c26a9e94198ed96ee9a47ef3ec7c Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:21:23 +0100 Subject: [PATCH 04/18] Refactored BasePanelMode to LibraryTab private --- .../java/org/jabref/gui/BasePanelMode.java | 11 ----- .../org/jabref/gui/library/LibraryTab.java | 49 +++++-------------- 2 files changed, 13 insertions(+), 47 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/BasePanelMode.java diff --git a/src/main/java/org/jabref/gui/BasePanelMode.java b/src/main/java/org/jabref/gui/BasePanelMode.java deleted file mode 100644 index 9305439ad2b..00000000000 --- a/src/main/java/org/jabref/gui/BasePanelMode.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.jabref.gui; - -/** - * Defines the different modes that the BasePanel can operate in - */ - -public enum BasePanelMode { - SHOWING_NOTHING, - SHOWING_EDITOR, - WILL_SHOW_EDITOR -} diff --git a/src/main/java/org/jabref/gui/library/LibraryTab.java b/src/main/java/org/jabref/gui/library/LibraryTab.java index e172b0eac77..d5cbdf4cafd 100644 --- a/src/main/java/org/jabref/gui/library/LibraryTab.java +++ b/src/main/java/org/jabref/gui/library/LibraryTab.java @@ -25,7 +25,6 @@ import javafx.scene.layout.BorderPane; import javafx.util.Duration; -import org.jabref.gui.BasePanelMode; import org.jabref.gui.DialogService; import org.jabref.gui.Globals; import org.jabref.gui.JabRefFrame; @@ -89,6 +88,11 @@ public class LibraryTab extends Tab { + /** + * Defines the different modes that the BasePanel can operate in + */ + private enum PanelMode { TABLE, TABLE_EDITOR } + private static final Logger LOGGER = LoggerFactory.getLogger(LibraryTab.class); private final JabRefFrame frame; private final CountingUndoManager undoManager; @@ -106,7 +110,7 @@ public class LibraryTab extends Tab { private FileAnnotationCache annotationCache; private EntryEditor entryEditor; private MainTable mainTable; - private BasePanelMode mode = BasePanelMode.SHOWING_NOTHING; + private PanelMode mode = PanelMode.TABLE; private SplitPane splitPane; private DatabaseNotification databaseNotificationPane; private boolean saving; @@ -409,14 +413,6 @@ public SuggestionProviders getSuggestionProviders() { return suggestionProviders; } - public BasePanelMode getMode() { - return mode; - } - - public void setMode(BasePanelMode mode) { - this.mode = mode; - } - public JabRefFrame frame() { return frame; } @@ -591,37 +587,22 @@ public EntryEditor getEntryEditor() { * @param entry The entry to edit. */ public void showAndEdit(BibEntry entry) { - showBottomPane(BasePanelMode.SHOWING_EDITOR); + mode = PanelMode.TABLE_EDITOR; + splitPane.setDividerPositions(preferencesService.getEntryEditorPreferences().getDividerPosition()); // We use != instead of equals because of performance reasons - if (entry != getShowing()) { + if (entry != showing) { entryEditor.setEntry(entry); showing = entry; } entryEditor.requestFocus(); } - private void showBottomPane(BasePanelMode newMode) { - if (newMode != BasePanelMode.SHOWING_EDITOR) { - throw new UnsupportedOperationException("new mode not recognized: " + newMode.name()); - } - Node pane = entryEditor; - - if (splitPane.getItems().size() == 2) { - splitPane.getItems().set(1, pane); - } else { - splitPane.getItems().add(1, pane); - } - mode = newMode; - - splitPane.setDividerPositions(preferencesService.getEntryEditorPreferences().getDividerPosition()); - } - /** * Removes the bottom component. */ public void closeBottomPane() { - mode = BasePanelMode.SHOWING_NOTHING; + mode = PanelMode.TABLE; splitPane.getItems().remove(entryEditor); } @@ -654,13 +635,13 @@ public void entryEditorClosing() { private void ensureNotShowingBottomPanel(List entriesToCheck) { // This method is not able to close the bottom pane currently - if ((mode == BasePanelMode.SHOWING_EDITOR) && (entriesToCheck.contains(entryEditor.getEntry()))) { + if ((mode == PanelMode.TABLE_EDITOR) && (entriesToCheck.contains(entryEditor.getEntry()))) { closeBottomPane(); } } public void updateEntryEditorIfShowing() { - if (mode == BasePanelMode.SHOWING_EDITOR) { + if (mode == PanelMode.TABLE_EDITOR) { BibEntry currentEntry = entryEditor.getEntry(); showAndEdit(currentEntry); } @@ -710,7 +691,7 @@ private boolean showDeleteConfirmationDialog(int numberOfEntries) { * Depending on whether a preview or an entry editor is showing, save the current divider location in the correct preference setting. */ private void saveDividerLocation(Number position) { - if (mode == BasePanelMode.SHOWING_EDITOR) { + if (mode == PanelMode.TABLE_EDITOR) { preferencesService.getEntryEditorPreferences().setDividerPosition(position.doubleValue()); } } @@ -745,10 +726,6 @@ public void setSaving(boolean saving) { this.saving = saving; } - private BibEntry getShowing() { - return showing; - } - public String formatOutputMessage(String start, int count) { return String.format("%s %d %s.", start, count, (count > 1 ? Localization.lang("entries") : Localization.lang("entry"))); } From 727d03b19351b60036bb789ab9c904ed5822d184 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Sun, 31 Dec 2023 02:06:29 +0100 Subject: [PATCH 05/18] Refactored closing library --- src/main/java/org/jabref/gui/JabRefFrame.java | 152 +++--------------- .../org/jabref/gui/library/LibraryTab.java | 98 +++++++++-- .../autosaveandbackup/BackupManagerTest.java | 3 +- 3 files changed, 113 insertions(+), 140 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index bf87940f39d..619fa761d46 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -17,8 +17,7 @@ import javafx.beans.binding.Bindings; import javafx.beans.binding.StringBinding; import javafx.collections.transformation.FilteredList; -import javafx.scene.control.Alert; -import javafx.scene.control.ButtonBar; +import javafx.event.Event; import javafx.scene.control.ButtonType; import javafx.scene.control.ContextMenu; import javafx.scene.control.SeparatorMenuItem; @@ -37,10 +36,7 @@ import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; -import org.jabref.gui.autosaveandbackup.AutosaveManager; -import org.jabref.gui.autosaveandbackup.BackupManager; import org.jabref.gui.desktop.JabRefDesktop; -import org.jabref.gui.exporter.SaveDatabaseAction; import org.jabref.gui.help.HelpAction; import org.jabref.gui.importer.ImportEntriesDialog; import org.jabref.gui.importer.NewEntryAction; @@ -62,7 +58,6 @@ import org.jabref.logic.importer.ImportCleanup; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; -import org.jabref.logic.shared.DatabaseLocation; import org.jabref.logic.undo.AddUndoableActionEvent; import org.jabref.logic.undo.UndoChangeEvent; import org.jabref.logic.undo.UndoRedoEvent; @@ -352,15 +347,7 @@ public void about() { new HelpAction(HelpFile.CONTENTS, dialogService, prefs.getFilePreferences()).execute(); } - /** - * Tears down all things started by JabRef - *

- * FIXME: Currently some threads remain and therefore hinder JabRef to be closed properly - * - * @param filenames the filenames of all currently opened files - used for storing them if prefs openLastEdited is - * set to true - */ - private void tearDownJabRef(List filenames) { + private void storeLastOpenedFiles(List filenames) { if (prefs.getWorkspacePreferences().shouldOpenLastEdited()) { // Here we store the names of all current files. If there is no current file, we remove any // previously stored filename. @@ -374,8 +361,6 @@ private void tearDownJabRef(List filenames) { prefs.getGuiPreferences().setLastFocusedFile(focusedDatabase); } } - - prefs.flush(); } /** @@ -385,7 +370,6 @@ private void tearDownJabRef(List filenames) { *

* Non-OSX JabRef calls this when choosing "Quit" from the menu *

- * SIDE EFFECT: tears down JabRef * * @return true if the user chose to quit; false otherwise */ @@ -407,22 +391,15 @@ public boolean quit() { // Then ask if the user really wants to close, if the library has not been saved since last save. List filenames = new ArrayList<>(); - for (int i = 0; i < tabbedPane.getTabs().size(); i++) { + for (int i = 0; i < getLibraryTabs().size(); i++) { LibraryTab libraryTab = getLibraryTabAt(i); - final BibDatabaseContext context = libraryTab.getBibDatabaseContext(); - if (libraryTab.isModified() && (context.getLocation() == DatabaseLocation.LOCAL)) { - tabbedPane.getSelectionModel().select(i); - if (!confirmClose(libraryTab)) { - return false; - } - } else if (context.getLocation() == DatabaseLocation.SHARED) { - context.convertToLocalDatabase(); - context.getDBMSSynchronizer().closeSharedDatabase(); - context.clearDBMSSynchronizer(); - } - AutosaveManager.shutdown(context); - BackupManager.shutdown(context, prefs.getFilePreferences().getBackupDirectory(), prefs.getFilePreferences().shouldCreateBackup()); - context.getDatabasePath().map(Path::toAbsolutePath).map(Path::toString).ifPresent(filenames::add); + closeTab(libraryTab); + + libraryTab.getBibDatabaseContext() + .getDatabasePath() + .map(Path::toAbsolutePath) + .map(Path::toString) + .ifPresent(filenames::add); } WaitForSaveFinishedDialog waitForSaveFinishedDialog = new WaitForSaveFinishedDialog(dialogService); @@ -430,8 +407,10 @@ public boolean quit() { // We call saveWindow state here again because under Mac the windowClose listener on the stage isn't triggered when using cmd + q saveWindowState(); - // Good bye! - tearDownJabRef(filenames); + storeLastOpenedFiles(filenames); + prefs.flush(); + + // Goodbye! Platform.exit(); return true; } @@ -528,7 +507,7 @@ private void updateSidePane() { splitPane.getItems().remove(sidePane); } else { if (!splitPane.getItems().contains(sidePane)) { - splitPane.getItems().add(0, sidePane); + splitPane.getItems().addFirst(sidePane); setDividerPosition(); } } @@ -547,7 +526,7 @@ private void setDividerPosition() { * @param i Index of base */ public LibraryTab getLibraryTabAt(int i) { - return (LibraryTab) tabbedPane.getTabs().get(i); + return getLibraryTabs().get(i); } /** @@ -723,12 +702,6 @@ public void addTab(LibraryTab libraryTab, boolean raisePanel) { tabbedPane.requestFocus(); } - libraryTab.setOnCloseRequest(event -> { - libraryTab.cancelLoading(); - closeTab(libraryTab); - event.consume(); - }); - libraryTab.setContextMenu(createTabContextMenuFor(libraryTab, Globals.getKeyPrefs())); libraryTab.getUndoManager().registerListener(new UndoRedoEventManager()); @@ -736,7 +709,7 @@ public void addTab(LibraryTab libraryTab, boolean raisePanel) { /** * Opens a new tab with existing data. - * Asynchronous loading is done at {@link LibraryTab#createLibraryTab(BackgroundTask, Path, DialogService, PreferencesService, StateManager, JabRefFrame, FileUpdateMonitor, BibEntryTypesManager, CountingUndoManager)}. + * Asynchronous loading is done at {@link LibraryTab#createLibraryTab}. */ public void addTab(BibDatabaseContext databaseContext, boolean raisePanel) { Objects.requireNonNull(databaseContext); @@ -805,96 +778,19 @@ public FileHistoryMenu getFileHistory() { return fileHistory; } - /** - * Ask if the user really wants to close the given database. - * Offers to save or discard the changes -- or return to the library - * - * @return true if the user choose to close the database - */ - private boolean confirmClose(LibraryTab libraryTab) { - String filename = libraryTab.getBibDatabaseContext() - .getDatabasePath() - .map(Path::toAbsolutePath) - .map(Path::toString) - .orElse(Localization.lang("untitled")); - - ButtonType saveChanges = new ButtonType(Localization.lang("Save changes"), ButtonBar.ButtonData.YES); - ButtonType discardChanges = new ButtonType(Localization.lang("Discard changes"), ButtonBar.ButtonData.NO); - ButtonType returnToLibrary = new ButtonType(Localization.lang("Return to library"), ButtonBar.ButtonData.CANCEL_CLOSE); - - Optional response = dialogService.showCustomButtonDialogAndWait(Alert.AlertType.CONFIRMATION, - Localization.lang("Save before closing"), - Localization.lang("Library '%0' has changed.", filename), - saveChanges, discardChanges, returnToLibrary); - - if (response.isEmpty()) { - return true; - } - - ButtonType buttonType = response.get(); - - if (buttonType.equals(returnToLibrary)) { - return false; - } - - if (buttonType.equals(saveChanges)) { - try { - SaveDatabaseAction saveAction = new SaveDatabaseAction(libraryTab, dialogService, prefs, Globals.entryTypesManager); - if (saveAction.save()) { - return true; - } - // The action was either canceled or unsuccessful. - dialogService.notify(Localization.lang("Unable to save library")); - } catch (Throwable ex) { - LOGGER.error("A problem occurred when trying to save the file", ex); - dialogService.showErrorDialogAndWait(Localization.lang("Save library"), Localization.lang("Could not save file."), ex); - } - // Save was cancelled or an error occurred. - return false; - } - - if (buttonType.equals(discardChanges)) { - BackupManager.discardBackup(libraryTab.getBibDatabaseContext(), prefs.getFilePreferences().getBackupDirectory()); - return true; - } - - return false; - } - public void closeTab(LibraryTab libraryTab) { - // empty tab without database - if (libraryTab == null) { - libraryTab = getCurrentLibraryTab(); - } - - final BibDatabaseContext context = libraryTab.getBibDatabaseContext(); - - if (libraryTab.isModified() && (context.getLocation() == DatabaseLocation.LOCAL)) { - if (confirmClose(libraryTab)) { - removeTab(libraryTab); - } else { - return; - } - } else if (context.getLocation() == DatabaseLocation.SHARED) { - context.convertToLocalDatabase(); - context.getDBMSSynchronizer().closeSharedDatabase(); - context.clearDBMSSynchronizer(); - removeTab(libraryTab); - } else { - removeTab(libraryTab); - } - AutosaveManager.shutdown(context); - BackupManager.shutdown(context, prefs.getFilePreferences().getBackupDirectory(), prefs.getFilePreferences().shouldCreateBackup()); - } - - private void removeTab(LibraryTab libraryTab) { DefaultTaskExecutor.runInJavaFXThread(() -> { + Event requestCloseEvent = new Event(this, libraryTab, Tab.TAB_CLOSE_REQUEST_EVENT); + Event.fireEvent(libraryTab, requestCloseEvent); + if (!requestCloseEvent.isConsumed()) { + Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); + } tabbedPane.getTabs().remove(libraryTab); }); } public void closeCurrentTab() { - removeTab(getCurrentLibraryTab()); + closeTab(getCurrentLibraryTab()); } public OpenDatabaseAction getOpenDatabaseAction() { @@ -941,7 +837,7 @@ private void copyGroupTreeNode(LibraryTab destinationLibraryTab, GroupTreeNode p } private void copyRootNode(LibraryTab destinationLibraryTab) { - if (!destinationLibraryTab.getBibDatabaseContext().getMetaData().getGroups().isEmpty()) { + if (destinationLibraryTab.getBibDatabaseContext().getMetaData().getGroups().isPresent()) { return; } // a root (all entries) GroupTreeNode diff --git a/src/main/java/org/jabref/gui/library/LibraryTab.java b/src/main/java/org/jabref/gui/library/LibraryTab.java index d5cbdf4cafd..87d297579fb 100644 --- a/src/main/java/org/jabref/gui/library/LibraryTab.java +++ b/src/main/java/org/jabref/gui/library/LibraryTab.java @@ -16,8 +16,12 @@ import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.collections.ListChangeListener; +import javafx.event.Event; import javafx.geometry.Orientation; import javafx.scene.Node; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonBar; +import javafx.scene.control.ButtonType; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.SplitPane; import javafx.scene.control.Tab; @@ -38,6 +42,7 @@ import org.jabref.gui.collab.DatabaseChangeMonitor; import org.jabref.gui.dialogs.AutosaveUiManager; import org.jabref.gui.entryeditor.EntryEditor; +import org.jabref.gui.exporter.SaveDatabaseAction; import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.MainTable; @@ -187,7 +192,8 @@ private LibraryTab(BibDatabaseContext bibDatabaseContext, updateTabTitle(changedProperty.getValue())); }); - setOnClosed(event -> cleanUp()); + setOnCloseRequest(this::onCloseRequest); + setOnClosed(this::onClosed); } private static void addChangedInformation(StringBuilder text, String fileName) { @@ -208,16 +214,10 @@ private static void addSharedDbInformation(StringBuilder text, BibDatabaseContex text.append("]"); } - public void setDataLoadingTask(BackgroundTask dataLoadingTask) { + private void setDataLoadingTask(BackgroundTask dataLoadingTask) { this.dataLoadingTask = dataLoadingTask; } - public void cancelLoading() { - if (dataLoadingTask != null) { - dataLoadingTask.cancel(); - } - } - /** * The layout to display in the tab when it's loading */ @@ -696,13 +696,89 @@ private void saveDividerLocation(Number position) { } } + private void onCloseRequest(Event event) { + if (isModified() && (bibDatabaseContext.getLocation() == DatabaseLocation.LOCAL)) { + if (!confirmClose()) { + event.consume(); + } + } else if (bibDatabaseContext.getLocation() == DatabaseLocation.SHARED) { + bibDatabaseContext.convertToLocalDatabase(); + bibDatabaseContext.getDBMSSynchronizer().closeSharedDatabase(); + bibDatabaseContext.clearDBMSSynchronizer(); + } + } + + /** + * Ask if the user really wants to close the given database. + * Offers to save or discard the changes -- or return to the library + * + * @return true if the user choose to close the database + */ + private boolean confirmClose() { + // Database could not have been changed, since it is still loading + if (dataLoadingTask != null) { + dataLoadingTask.cancel(); + return true; + } + + String filename = getBibDatabaseContext() + .getDatabasePath() + .map(Path::toAbsolutePath) + .map(Path::toString) + .orElse(Localization.lang("untitled")); + + ButtonType saveChanges = new ButtonType(Localization.lang("Save changes"), ButtonBar.ButtonData.YES); + ButtonType discardChanges = new ButtonType(Localization.lang("Discard changes"), ButtonBar.ButtonData.NO); + ButtonType returnToLibrary = new ButtonType(Localization.lang("Return to library"), ButtonBar.ButtonData.CANCEL_CLOSE); + + Optional response = dialogService.showCustomButtonDialogAndWait(Alert.AlertType.CONFIRMATION, + Localization.lang("Save before closing"), + Localization.lang("Library '%0' has changed.", filename), + saveChanges, discardChanges, returnToLibrary); + + if (response.isEmpty()) { + return true; + } + + ButtonType buttonType = response.get(); + + if (buttonType.equals(returnToLibrary)) { + return false; + } + + if (buttonType.equals(saveChanges)) { + try { + SaveDatabaseAction saveAction = new SaveDatabaseAction(this, dialogService, preferencesService, Globals.entryTypesManager); + if (saveAction.save()) { + return true; + } + // The action was either canceled or unsuccessful. + dialogService.notify(Localization.lang("Unable to save library")); + } catch (Throwable ex) { + LOGGER.error("A problem occurred when trying to save the file", ex); + dialogService.showErrorDialogAndWait(Localization.lang("Save library"), Localization.lang("Could not save file."), ex); + } + // Save was cancelled or an error occurred. + return false; + } + + if (buttonType.equals(discardChanges)) { + BackupManager.discardBackup(bibDatabaseContext, preferencesService.getFilePreferences().getBackupDirectory()); + return true; + } + + return false; + } + /** - * Perform necessary cleanup when this BasePanel is closed. + * Perform necessary cleanup when this Library is closed. */ - private void cleanUp() { + private void onClosed(Event event) { changeMonitor.ifPresent(DatabaseChangeMonitor::unregister); AutosaveManager.shutdown(bibDatabaseContext); - BackupManager.shutdown(bibDatabaseContext, preferencesService.getFilePreferences().getBackupDirectory(), preferencesService.getFilePreferences().shouldCreateBackup()); + BackupManager.shutdown(bibDatabaseContext, + preferencesService.getFilePreferences().getBackupDirectory(), + preferencesService.getFilePreferences().shouldCreateBackup()); } /** diff --git a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java index 33542102f63..4c6181296c7 100644 --- a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java +++ b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java @@ -141,6 +141,7 @@ public void shouldNotCreateABackup(@TempDir Path customDir) throws Exception { var filePreferences = mock(FilePreferences.class); when(preferences.getFilePreferences()).thenReturn(filePreferences); when(filePreferences.getBackupDirectory()).thenReturn(backupDir); + when(filePreferences.shouldCreateBackup()).thenReturn(false); BackupManager manager = BackupManager.start( mock(LibraryTab.class), @@ -149,7 +150,7 @@ public void shouldNotCreateABackup(@TempDir Path customDir) throws Exception { preferences); manager.listen(new MetaDataChangedEvent(new MetaData())); - BackupManager.shutdown(database, backupDir, false); + BackupManager.shutdown(database, filePreferences); List files = Files.list(backupDir).toList(); assertEquals(Collections.emptyList(), files); From a3c911abb4e85468de22838ed98c88288834467a Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Sun, 31 Dec 2023 02:25:57 +0100 Subject: [PATCH 06/18] Extracted dnd methods --- src/main/java/org/jabref/gui/JabRefFrame.java | 183 +++++++++--------- 1 file changed, 95 insertions(+), 88 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 619fa761d46..ae28b92cfa1 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -18,6 +18,7 @@ import javafx.beans.binding.StringBinding; import javafx.collections.transformation.FilteredList; import javafx.event.Event; +import javafx.scene.Node; import javafx.scene.control.ButtonType; import javafx.scene.control.ContextMenu; import javafx.scene.control.SeparatorMenuItem; @@ -25,6 +26,7 @@ import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.control.skin.TabPaneSkin; +import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.KeyEvent; import javafx.scene.input.TransferMode; @@ -140,104 +142,109 @@ private void initDragAndDrop() { return; } // Add drag and drop listeners to JabRefFrame - this.getScene().setOnDragOver(event -> { - if (DragAndDropHelper.hasBibFiles(event.getDragboard())) { - event.acceptTransferModes(TransferMode.ANY); - if (!tabbedPane.getTabs().contains(dndIndicator)) { - tabbedPane.getTabs().add(dndIndicator); - } - event.consume(); - } else { - tabbedPane.getTabs().remove(dndIndicator); - } - // Accept drag entries from MainTable - if (event.getDragboard().hasContent(DragAndDropDataFormats.ENTRIES)) { - event.acceptTransferModes(TransferMode.COPY); - event.consume(); - } - }); - + this.getScene().setOnDragOver(event -> onSceneDragOver(event, dndIndicator)); this.getScene().setOnDragEntered(event -> { // It is necessary to setOnDragOver for newly opened tabs // drag'n'drop on tabs covered dnd on tabbedPane, so dnd on tabs should contain all dnds on tabbedPane - tabbedPane.lookupAll(".tab").forEach(destinationTabNode -> { - destinationTabNode.setOnDragOver(tabDragEvent -> { - if (DragAndDropHelper.hasBibFiles(tabDragEvent.getDragboard()) || DragAndDropHelper.hasGroups(tabDragEvent.getDragboard())) { - tabDragEvent.acceptTransferModes(TransferMode.ANY); - if (!tabbedPane.getTabs().contains(dndIndicator)) { - tabbedPane.getTabs().add(dndIndicator); - } - event.consume(); - } else { - tabbedPane.getTabs().remove(dndIndicator); - } - - if (tabDragEvent.getDragboard().hasContent(DragAndDropDataFormats.ENTRIES)) { - tabDragEvent.acceptTransferModes(TransferMode.COPY); - tabDragEvent.consume(); - } - }); + for (Node destinationTabNode : tabbedPane.lookupAll(".tab")) { + destinationTabNode.setOnDragOver(tabDragEvent -> onTabDragOver(event, tabDragEvent, dndIndicator)); destinationTabNode.setOnDragExited(event1 -> tabbedPane.getTabs().remove(dndIndicator)); - destinationTabNode.setOnDragDropped(tabDragEvent -> { - - Dragboard dragboard = tabDragEvent.getDragboard(); - - if (DragAndDropHelper.hasBibFiles(dragboard)) { - tabbedPane.getTabs().remove(dndIndicator); - List bibFiles = DragAndDropHelper.getBibFiles(dragboard); - OpenDatabaseAction openDatabaseAction = this.getOpenDatabaseAction(); - openDatabaseAction.openFiles(bibFiles); - tabDragEvent.setDropCompleted(true); - tabDragEvent.consume(); - } else { - for (Tab libraryTab : tabbedPane.getTabs()) { - if (libraryTab.getId().equals(destinationTabNode.getId()) && - !tabbedPane.getSelectionModel().getSelectedItem().equals(libraryTab)) { - LibraryTab destinationLibraryTab = (LibraryTab) libraryTab; - if (DragAndDropHelper.hasGroups(dragboard)) { - List groupPathToSources = DragAndDropHelper.getGroups(dragboard); - - copyRootNode(destinationLibraryTab); - - GroupTreeNode destinationLibraryGroupRoot = destinationLibraryTab - .getBibDatabaseContext() - .getMetaData() - .getGroups().get(); - - for (String pathToSource : groupPathToSources) { - GroupTreeNode groupTreeNodeToCopy = getCurrentLibraryTab() - .getBibDatabaseContext() - .getMetaData() - .getGroups() - .get() - .getChildByPath(pathToSource) - .get(); - copyGroupTreeNode((LibraryTab) libraryTab, destinationLibraryGroupRoot, groupTreeNodeToCopy); - } - return; - } - destinationLibraryTab.dropEntry(stateManager.getLocalDragboard().getBibEntries()); - } - } - tabDragEvent.consume(); - } - }); - }); + destinationTabNode.setOnDragDropped(tabDragEvent -> onTabDragDropped(destinationTabNode, tabDragEvent, dndIndicator)); + } event.consume(); }); - this.getScene().setOnDragExited(event -> tabbedPane.getTabs().remove(dndIndicator)); - this.getScene().setOnDragDropped(event -> { - tabbedPane.getTabs().remove(dndIndicator); - List bibFiles = DragAndDropHelper.getBibFiles(event.getDragboard()); - OpenDatabaseAction openDatabaseAction = this.getOpenDatabaseAction(); - openDatabaseAction.openFiles(bibFiles); - event.setDropCompleted(true); - event.consume(); - }); + this.getScene().setOnDragDropped(event -> onSceneDragDropped(event, dndIndicator)); }); } + private void onTabDragDropped(Node destinationTabNode, DragEvent tabDragEvent, Tab dndIndicator) { + Dragboard dragboard = tabDragEvent.getDragboard(); + + if (DragAndDropHelper.hasBibFiles(dragboard)) { + tabbedPane.getTabs().remove(dndIndicator); + List bibFiles = DragAndDropHelper.getBibFiles(dragboard); + OpenDatabaseAction openDatabaseAction = this.getOpenDatabaseAction(); + openDatabaseAction.openFiles(bibFiles); + tabDragEvent.setDropCompleted(true); + tabDragEvent.consume(); + } else { + for (Tab libraryTab : tabbedPane.getTabs()) { + if (libraryTab.getId().equals(destinationTabNode.getId()) && + !tabbedPane.getSelectionModel().getSelectedItem().equals(libraryTab)) { + LibraryTab destinationLibraryTab = (LibraryTab) libraryTab; + if (DragAndDropHelper.hasGroups(dragboard)) { + List groupPathToSources = DragAndDropHelper.getGroups(dragboard); + + copyRootNode(destinationLibraryTab); + + GroupTreeNode destinationLibraryGroupRoot = destinationLibraryTab + .getBibDatabaseContext() + .getMetaData() + .getGroups().get(); + + for (String pathToSource : groupPathToSources) { + GroupTreeNode groupTreeNodeToCopy = getCurrentLibraryTab() + .getBibDatabaseContext() + .getMetaData() + .getGroups() + .get() + .getChildByPath(pathToSource) + .get(); + copyGroupTreeNode((LibraryTab) libraryTab, destinationLibraryGroupRoot, groupTreeNodeToCopy); + } + return; + } + destinationLibraryTab.dropEntry(stateManager.getLocalDragboard().getBibEntries()); + } + } + tabDragEvent.consume(); + } + } + + private void onTabDragOver(DragEvent event, DragEvent tabDragEvent, Tab dndIndicator) { + if (DragAndDropHelper.hasBibFiles(tabDragEvent.getDragboard()) || DragAndDropHelper.hasGroups(tabDragEvent.getDragboard())) { + tabDragEvent.acceptTransferModes(TransferMode.ANY); + if (!tabbedPane.getTabs().contains(dndIndicator)) { + tabbedPane.getTabs().add(dndIndicator); + } + event.consume(); + } else { + tabbedPane.getTabs().remove(dndIndicator); + } + + if (tabDragEvent.getDragboard().hasContent(DragAndDropDataFormats.ENTRIES)) { + tabDragEvent.acceptTransferModes(TransferMode.COPY); + tabDragEvent.consume(); + } + } + + private void onSceneDragOver(DragEvent event, Tab dndIndicator) { + if (DragAndDropHelper.hasBibFiles(event.getDragboard())) { + event.acceptTransferModes(TransferMode.ANY); + if (!tabbedPane.getTabs().contains(dndIndicator)) { + tabbedPane.getTabs().add(dndIndicator); + } + event.consume(); + } else { + tabbedPane.getTabs().remove(dndIndicator); + } + // Accept drag entries from MainTable + if (event.getDragboard().hasContent(DragAndDropDataFormats.ENTRIES)) { + event.acceptTransferModes(TransferMode.COPY); + event.consume(); + } + } + + private void onSceneDragDropped(DragEvent event, Tab dndIndicator) { + tabbedPane.getTabs().remove(dndIndicator); + List bibFiles = DragAndDropHelper.getBibFiles(event.getDragboard()); + OpenDatabaseAction openDatabaseAction = this.getOpenDatabaseAction(); + openDatabaseAction.openFiles(bibFiles); + event.setDropCompleted(true); + event.consume(); + } + private void initKeyBindings() { addEventFilter(KeyEvent.KEY_PRESSED, event -> { Optional keyBinding = Globals.getKeyPrefs().mapToKeyBinding(event); From 119052df08dc513b9535a7a5d096e20694bb5a7e Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:46:17 +0100 Subject: [PATCH 07/18] Fixed merge errors --- src/main/java/org/jabref/gui/JabRefFrame.java | 2 +- .../gui/citationkeypattern/GenerateCitationKeyAction.java | 2 +- src/main/java/org/jabref/gui/cleanup/CleanupAction.java | 2 +- src/main/java/org/jabref/gui/edit/EditAction.java | 2 +- src/main/java/org/jabref/gui/edit/ReplaceStringAction.java | 2 +- .../java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java | 2 +- .../java/org/jabref/gui/entryeditor/PreviewSwitchAction.java | 2 +- src/main/java/org/jabref/gui/exporter/SaveAction.java | 2 +- src/main/java/org/jabref/gui/importer/NewEntryAction.java | 2 +- .../org/jabref/gui/importer/actions/OpenDatabaseAction.java | 1 + .../java/org/jabref/gui/integrity/IntegrityCheckAction.java | 2 +- src/main/java/org/jabref/gui/journals/AbbreviateAction.java | 2 +- src/main/java/org/jabref/gui/library/LibraryTab.java | 2 +- .../java/org/jabref/gui/specialfields/SpecialFieldAction.java | 2 +- .../jabref/gui/specialfields/SpecialFieldMenuItemFactory.java | 2 +- .../org/jabref/gui/specialfields/SpecialFieldViewModel.java | 2 +- src/main/resources/csl-styles | 2 +- src/test/java/org/jabref/gui/importer/NewEntryActionTest.java | 1 + 18 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index b9bb60c42a7..f29c159ccc7 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -846,7 +846,7 @@ public Stage getMainStage() { public void refresh() { globalSearchBar.updateHintVisibility(); setupAllTables(); - getLibraryTabs().forEach(panel -> panel.getMainTable().getTableModel().refresh()); + getLibraryTabs().forEach(panel -> panel.getMainTable().getTableModel().resetFieldFormatter()); } /** diff --git a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java index b5fd088e9d1..f9a517c9f66 100644 --- a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java +++ b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java @@ -7,10 +7,10 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableKeyChange; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupAction.java b/src/main/java/org/jabref/gui/cleanup/CleanupAction.java index f4f75a2ad74..42f4e0b586a 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupAction.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupAction.java @@ -7,10 +7,10 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/edit/EditAction.java b/src/main/java/org/jabref/gui/edit/EditAction.java index be8472a1585..08f8663a99a 100644 --- a/src/main/java/org/jabref/gui/edit/EditAction.java +++ b/src/main/java/org/jabref/gui/edit/EditAction.java @@ -7,11 +7,11 @@ import javafx.scene.control.TextInputControl; import javafx.scene.web.WebView; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; +import org.jabref.gui.library.LibraryTab; import org.fxmisc.richtext.CodeArea; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java b/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java index 8339b5db7f3..086a3f5c119 100644 --- a/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java +++ b/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java @@ -3,10 +3,10 @@ import java.util.function.Supplier; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; public class ReplaceStringAction extends SimpleCommand { private final Supplier tabSupplier; diff --git a/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java b/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java index 36758215401..6ffebb79cc1 100644 --- a/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java +++ b/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java @@ -2,10 +2,10 @@ import java.util.function.Supplier; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; public class OpenEntryEditorAction extends SimpleCommand { diff --git a/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java b/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java index aa98a5b7e24..bd4dc6b915e 100644 --- a/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java +++ b/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java @@ -2,9 +2,9 @@ import java.util.function.Supplier; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import static org.jabref.gui.actions.ActionHelper.needsDatabase; diff --git a/src/main/java/org/jabref/gui/exporter/SaveAction.java b/src/main/java/org/jabref/gui/exporter/SaveAction.java index d4fe785f229..ce523eedc9c 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveAction.java @@ -4,10 +4,10 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.preferences.PreferencesService; /** diff --git a/src/main/java/org/jabref/gui/importer/NewEntryAction.java b/src/main/java/org/jabref/gui/importer/NewEntryAction.java index 4737211f7fb..36f92ba17d2 100644 --- a/src/main/java/org/jabref/gui/importer/NewEntryAction.java +++ b/src/main/java/org/jabref/gui/importer/NewEntryAction.java @@ -7,11 +7,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.EntryTypeView; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.Telemetry; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.types.EntryType; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java index a3fa499d73e..a7cecd4e3c4 100644 --- a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java @@ -14,6 +14,7 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.Telemetry; import org.jabref.gui.actions.SimpleCommand; diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java index 472efce865e..11e16943d5d 100644 --- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java +++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java @@ -8,9 +8,9 @@ import javafx.concurrent.Task; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.integrity.IntegrityCheck; import org.jabref.logic.integrity.IntegrityMessage; diff --git a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java index c876418fc4e..db92a15c0ec 100644 --- a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java +++ b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java @@ -13,11 +13,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; import org.jabref.gui.JabRefExecutorService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; diff --git a/src/main/java/org/jabref/gui/library/LibraryTab.java b/src/main/java/org/jabref/gui/library/LibraryTab.java index 916f00cd7d1..8e1d9a7cb2f 100644 --- a/src/main/java/org/jabref/gui/library/LibraryTab.java +++ b/src/main/java/org/jabref/gui/library/LibraryTab.java @@ -31,7 +31,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; -import org.jabref.gui.JabRefFrame; +import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.UpdateTimestampListener; import org.jabref.gui.autocompleter.AutoCompletePreferences; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java index fc256c69b56..241305aac05 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java @@ -9,10 +9,10 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java index 47ec0ac27e4..9ecd1a733b2 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java @@ -9,9 +9,9 @@ import javafx.scene.control.MenuItem; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionFactory; +import org.jabref.gui.library.LibraryTab; import org.jabref.model.entry.field.SpecialField; import org.jabref.model.entry.field.SpecialFieldValue; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java index ddda94ea1c6..ba614ef0c60 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java @@ -9,11 +9,11 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; -import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.Action; import org.jabref.gui.actions.StandardActions; import org.jabref.gui.icon.JabRefIcon; +import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.logic.util.UpdateField; import org.jabref.model.FieldChange; diff --git a/src/main/resources/csl-styles b/src/main/resources/csl-styles index eedecef83f6..9c43a7dacc1 160000 --- a/src/main/resources/csl-styles +++ b/src/main/resources/csl-styles @@ -1 +1 @@ -Subproject commit eedecef83f6a02dfc2068fc382b561045653b4b2 +Subproject commit 9c43a7dacc170d7f0225b53603e5dbc1666aaeb0 diff --git a/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java b/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java index c96a0d7bc42..c0aab5170f3 100644 --- a/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java +++ b/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java @@ -3,6 +3,7 @@ import java.util.List; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.OptionalObjectProperty; From f23572480a1b8794d7bd1bea10641f5c51cf2064 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:58:44 +0100 Subject: [PATCH 08/18] Fixed closing issues --- src/main/java/org/jabref/gui/JabRefFrame.java | 52 ++++++++++++------- .../org/jabref/gui/LibraryTabContainer.java | 2 +- .../org/jabref/gui/library/LibraryTab.java | 16 ++++-- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index f29c159ccc7..7840c467017 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -2,7 +2,6 @@ import java.io.IOException; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -396,16 +395,17 @@ public boolean quit() { } } - // Then ask if the user really wants to close, if the library has not been saved since last save. - List filenames = new ArrayList<>(); - for (LibraryTab libraryTab : getLibraryTabs()) { - closeTab(libraryTab); + List filenames = getLibraryTabs().stream() + .map(LibraryTab::getBibDatabaseContext) + .map(BibDatabaseContext::getDatabasePath) + .flatMap(Optional::stream) + .map(Path::toAbsolutePath) + .map(Path::toString) + .collect(Collectors.toList()); - libraryTab.getBibDatabaseContext() - .getDatabasePath() - .map(Path::toAbsolutePath) - .map(Path::toString) - .ifPresent(filenames::add); + // Then ask if the user really wants to close, if the library has not been saved since last save. + if (!closeTabs()) { + return false; } WaitForSaveFinishedDialog waitForSaveFinishedDialog = new WaitForSaveFinishedDialog(dialogService); @@ -761,15 +761,31 @@ public FileHistoryMenu getFileHistory() { return fileHistory; } - public void closeTab(LibraryTab libraryTab) { - DefaultTaskExecutor.runInJavaFXThread(() -> { - Event requestCloseEvent = new Event(this, libraryTab, Tab.TAB_CLOSE_REQUEST_EVENT); - Event.fireEvent(libraryTab, requestCloseEvent); - if (!requestCloseEvent.isConsumed()) { - Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); - } + public boolean closeTab(LibraryTab libraryTab) { + Event requestCloseEvent = new Event(this, libraryTab, Tab.TAB_CLOSE_REQUEST_EVENT); + Event.fireEvent(libraryTab, requestCloseEvent); + if (!requestCloseEvent.isConsumed()) { + Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); tabbedPane.getTabs().remove(libraryTab); - }); + return true; + } + return false; + } + + private boolean closeTabs() { + // Ask before closing any tab, if any tab has changes + for (LibraryTab libraryTab : getLibraryTabs()) { + if (!libraryTab.requestClose()) { + return false; + } + } + + // Close after checking for changes and saving all databases + for (LibraryTab libraryTab : getLibraryTabs()) { + Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); +// tabbedPane.getTabs().remove(libraryTab); + } + return true; } public void closeCurrentTab() { diff --git a/src/main/java/org/jabref/gui/LibraryTabContainer.java b/src/main/java/org/jabref/gui/LibraryTabContainer.java index 16d78c15a2f..32aa5c99e91 100644 --- a/src/main/java/org/jabref/gui/LibraryTabContainer.java +++ b/src/main/java/org/jabref/gui/LibraryTabContainer.java @@ -16,7 +16,7 @@ public interface LibraryTabContainer { void addTab(BibDatabaseContext bibDatabaseContext, boolean raisePanel); - void closeTab(LibraryTab libraryTab); + boolean closeTab(LibraryTab libraryTab); void closeCurrentTab(); diff --git a/src/main/java/org/jabref/gui/library/LibraryTab.java b/src/main/java/org/jabref/gui/library/LibraryTab.java index 8e1d9a7cb2f..080b8dc1dca 100644 --- a/src/main/java/org/jabref/gui/library/LibraryTab.java +++ b/src/main/java/org/jabref/gui/library/LibraryTab.java @@ -250,6 +250,8 @@ public void onDatabaseLoadingSucceed(ParserResult result) { LOGGER.error("Cannot access lucene index", e); } } + + dataLoadingTask = null; } public void onDatabaseLoadingFailed(Exception ex) { @@ -689,16 +691,16 @@ private void saveDividerLocation(Number position) { } } - private void onCloseRequest(Event event) { + public boolean requestClose() { if (isModified() && (bibDatabaseContext.getLocation() == DatabaseLocation.LOCAL)) { - if (!confirmClose()) { - event.consume(); - } + return confirmClose(); } else if (bibDatabaseContext.getLocation() == DatabaseLocation.SHARED) { bibDatabaseContext.convertToLocalDatabase(); bibDatabaseContext.getDBMSSynchronizer().closeSharedDatabase(); bibDatabaseContext.clearDBMSSynchronizer(); } + + return true; } /** @@ -763,6 +765,12 @@ private boolean confirmClose() { return false; } + private void onCloseRequest(Event event) { + if (!requestClose()) { + event.consume(); + } + } + /** * Perform necessary cleanup when this Library is closed. */ From 7bd98c3c32b464fb26d90be0800ddae26823ded4 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 9 Jan 2024 22:43:48 +0100 Subject: [PATCH 09/18] Fixed entry editor showing --- src/main/java/org/jabref/gui/library/LibraryTab.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/library/LibraryTab.java b/src/main/java/org/jabref/gui/library/LibraryTab.java index 080b8dc1dca..322628039ac 100644 --- a/src/main/java/org/jabref/gui/library/LibraryTab.java +++ b/src/main/java/org/jabref/gui/library/LibraryTab.java @@ -582,8 +582,11 @@ public EntryEditor getEntryEditor() { * @param entry The entry to edit. */ public void showAndEdit(BibEntry entry) { - mode = PanelMode.TABLE_EDITOR; - splitPane.setDividerPositions(preferencesService.getEntryEditorPreferences().getDividerPosition()); + if (!splitPane.getItems().contains(entryEditor)) { + splitPane.getItems().addLast(entryEditor); + mode = PanelMode.TABLE_EDITOR; + splitPane.setDividerPositions(preferencesService.getEntryEditorPreferences().getDividerPosition()); + } // We use != instead of equals because of performance reasons if (entry != showing) { From 3abc4a88082d0b4357f335796b6cb066f5ce10ba Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 9 Jan 2024 22:50:21 +0100 Subject: [PATCH 10/18] Reverted c6e53731 --- src/main/java/org/jabref/gui/EntryTypeView.java | 1 - src/main/java/org/jabref/gui/EntryTypeViewModel.java | 1 - src/main/java/org/jabref/gui/JabRefFrame.java | 3 +-- src/main/java/org/jabref/gui/JabRefGUI.java | 1 - .../java/org/jabref/gui/{library => }/LibraryTab.java | 9 ++------- src/main/java/org/jabref/gui/LibraryTabContainer.java | 1 - .../java/org/jabref/gui/WaitForSaveFinishedDialog.java | 1 - .../org/jabref/gui/autosaveandbackup/BackupManager.java | 2 +- .../citationkeypattern/GenerateCitationKeyAction.java | 2 +- src/main/java/org/jabref/gui/cleanup/CleanupAction.java | 2 +- .../org/jabref/gui/collab/DatabaseChangeMonitor.java | 2 +- .../java/org/jabref/gui/dialogs/AutosaveUiManager.java | 2 +- .../jabref/gui/duplicationFinder/DuplicateSearch.java | 2 +- src/main/java/org/jabref/gui/edit/EditAction.java | 2 +- .../java/org/jabref/gui/edit/ReplaceStringAction.java | 2 +- src/main/java/org/jabref/gui/edit/ReplaceStringView.java | 2 +- .../java/org/jabref/gui/edit/ReplaceStringViewModel.java | 2 +- .../automaticfiededitor/NotificationPaneAdapter.java | 2 +- .../java/org/jabref/gui/entryeditor/EntryEditor.java | 2 +- .../jabref/gui/entryeditor/OpenEntryEditorAction.java | 2 +- .../org/jabref/gui/entryeditor/PreviewSwitchAction.java | 2 +- .../citationrelationtab/CitationRelationsTab.java | 2 +- src/main/java/org/jabref/gui/exporter/ExportCommand.java | 2 +- src/main/java/org/jabref/gui/exporter/SaveAction.java | 2 +- src/main/java/org/jabref/gui/exporter/SaveAllAction.java | 2 +- .../java/org/jabref/gui/exporter/SaveDatabaseAction.java | 2 +- .../jabref/gui/importer/GenerateEntryFromIdAction.java | 2 +- .../jabref/gui/importer/GenerateEntryFromIdDialog.java | 2 +- .../java/org/jabref/gui/importer/NewEntryAction.java | 2 +- .../importer/actions/CheckForNewEntryTypesAction.java | 1 - .../jabref/gui/importer/actions/OpenDatabaseAction.java | 2 +- .../org/jabref/gui/integrity/IntegrityCheckAction.java | 2 +- .../org/jabref/gui/integrity/IntegrityCheckDialog.java | 2 +- .../java/org/jabref/gui/journals/AbbreviateAction.java | 2 +- .../java/org/jabref/gui/linkedfile/AttachFileAction.java | 2 +- src/main/java/org/jabref/gui/maintable/MainTable.java | 2 +- .../java/org/jabref/gui/maintable/RightClickMenu.java | 2 +- .../java/org/jabref/gui/openoffice/OpenOfficePanel.java | 2 +- .../gui/search/RebuildFulltextSearchIndexAction.java | 2 +- .../gui/shared/SharedDatabaseLoginDialogViewModel.java | 2 +- .../org/jabref/gui/shared/SharedDatabaseUIManager.java | 2 +- .../org/jabref/gui/specialfields/SpecialFieldAction.java | 2 +- .../gui/specialfields/SpecialFieldMenuItemFactory.java | 2 +- .../jabref/gui/specialfields/SpecialFieldViewModel.java | 2 +- src/main/java/org/jabref/gui/undo/UndoRedoAction.java | 2 +- .../jabref/logic/pdf/search/indexing/DocumentReader.java | 2 +- .../org/jabref/logic/pdf/search/indexing/PdfIndexer.java | 2 +- .../jabref/logic/pdf/search/retrieval/PdfSearcher.java | 2 +- .../org/jabref/model/database/BibDatabaseContext.java | 2 +- .../autosaveandbackup/BackupManagerDiscardedTest.java | 2 +- .../jabref/gui/autosaveandbackup/BackupManagerTest.java | 2 +- .../org/jabref/gui/edit/ReplaceStringViewModelTest.java | 2 +- .../org/jabref/gui/exporter/SaveDatabaseActionTest.java | 3 +-- .../java/org/jabref/gui/importer/NewEntryActionTest.java | 2 +- 54 files changed, 49 insertions(+), 62 deletions(-) rename src/main/java/org/jabref/gui/{library => }/LibraryTab.java (99%) diff --git a/src/main/java/org/jabref/gui/EntryTypeView.java b/src/main/java/org/jabref/gui/EntryTypeView.java index 6f783302379..3b10205a547 100644 --- a/src/main/java/org/jabref/gui/EntryTypeView.java +++ b/src/main/java/org/jabref/gui/EntryTypeView.java @@ -17,7 +17,6 @@ import javafx.scene.layout.FlowPane; import javafx.stage.Screen; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.IconValidationDecorator; diff --git a/src/main/java/org/jabref/gui/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/EntryTypeViewModel.java index 5b61b3e8263..b63718edeaf 100644 --- a/src/main/java/org/jabref/gui/EntryTypeViewModel.java +++ b/src/main/java/org/jabref/gui/EntryTypeViewModel.java @@ -16,7 +16,6 @@ import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.importer.NewEntryAction; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.importer.FetcherClientException; import org.jabref.logic.importer.FetcherException; diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 7840c467017..4c62476bfe0 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -44,7 +44,6 @@ import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.libraryproperties.LibraryPropertiesAction; import org.jabref.gui.menus.FileHistoryMenu; import org.jabref.gui.push.PushToApplicationCommand; @@ -571,7 +570,7 @@ public void init() { openDatabaseList = EasyBind.map(filteredTabs, tab -> ((LibraryTab) tab).getBibDatabaseContext()); EasyBind.bindContent(stateManager.getOpenDatabases(), openDatabaseList); - // the binding for stateManager.activeDatabaseProperty() is at org.jabref.gui.library.LibraryTab.onDatabaseLoadingSucceed + // the binding for stateManager.activeDatabaseProperty() is at org.jabref.gui.LibraryTab.onDatabaseLoadingSucceed // Subscribe to the search EasyBind.subscribe(stateManager.activeSearchQueryProperty(), diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index d6bd15434ec..134ff626773 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -18,7 +18,6 @@ import org.jabref.gui.importer.ParserResultWarningDialog; import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.TextInputKeyBindings; -import org.jabref.gui.library.LibraryTab; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; import org.jabref.logic.net.ProxyRegisterer; diff --git a/src/main/java/org/jabref/gui/library/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java similarity index 99% rename from src/main/java/org/jabref/gui/library/LibraryTab.java rename to src/main/java/org/jabref/gui/LibraryTab.java index 322628039ac..ace950d8c0f 100644 --- a/src/main/java/org/jabref/gui/library/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -1,4 +1,4 @@ -package org.jabref.gui.library; +package org.jabref.gui; import java.io.IOException; import java.nio.file.Path; @@ -29,11 +29,6 @@ import javafx.scene.layout.BorderPane; import javafx.util.Duration; -import org.jabref.gui.DialogService; -import org.jabref.gui.Globals; -import org.jabref.gui.LibraryTabContainer; -import org.jabref.gui.StateManager; -import org.jabref.gui.UpdateTimestampListener; import org.jabref.gui.autocompleter.AutoCompletePreferences; import org.jabref.gui.autocompleter.PersonNameSuggestionProvider; import org.jabref.gui.autocompleter.SuggestionProvider; @@ -267,7 +262,7 @@ public void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { // At that point, the library tab is given a temporary bibDatabaseContext with no entries. // This line is necessary because, while there is already a binding that updates the active database when a new tab is added, // it doesn't handle the case when a library is loaded asynchronously. - // See org.jabref.gui.library.LibraryTab.createLibraryTab for the asynchronous loading. + // See org.jabref.gui.LibraryTab.createLibraryTab for the asynchronous loading. stateManager.setActiveDatabase(bibDatabaseContextFromParserResult); } diff --git a/src/main/java/org/jabref/gui/LibraryTabContainer.java b/src/main/java/org/jabref/gui/LibraryTabContainer.java index 32aa5c99e91..544644cdf52 100644 --- a/src/main/java/org/jabref/gui/LibraryTabContainer.java +++ b/src/main/java/org/jabref/gui/LibraryTabContainer.java @@ -2,7 +2,6 @@ import java.util.List; -import org.jabref.gui.library.LibraryTab; import org.jabref.model.database.BibDatabaseContext; public interface LibraryTabContainer { diff --git a/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java b/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java index 637ce73b949..43f784669de 100644 --- a/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java +++ b/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java @@ -4,7 +4,6 @@ import javafx.concurrent.Task; -import org.jabref.gui.library.LibraryTab; import org.jabref.logic.l10n.Localization; /** diff --git a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java index a4732494269..1b9017f192f 100644 --- a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java @@ -21,7 +21,7 @@ import javafx.scene.control.TableColumn; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.logic.bibtex.InvalidFieldValueException; diff --git a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java index f9a517c9f66..b5fd088e9d1 100644 --- a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java +++ b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java @@ -7,10 +7,10 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableKeyChange; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupAction.java b/src/main/java/org/jabref/gui/cleanup/CleanupAction.java index 42f4e0b586a..f4f75a2ad74 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupAction.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupAction.java @@ -7,10 +7,10 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java index 5429bd4e3aa..fed43800e19 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java @@ -7,8 +7,8 @@ import javafx.util.Duration; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java b/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java index 93469dc82ac..ace8e2a18ad 100644 --- a/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java +++ b/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java @@ -1,8 +1,8 @@ package org.jabref.gui.dialogs; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.exporter.SaveDatabaseAction; -import org.jabref.gui.library.LibraryTab; import org.jabref.model.database.event.AutosaveEvent; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java index fca2bb0eea0..a6bb39a936f 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java @@ -18,11 +18,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefExecutorService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.duplicationFinder.DuplicateResolverDialog.DuplicateResolverResult; import org.jabref.gui.duplicationFinder.DuplicateResolverDialog.DuplicateResolverType; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableInsertEntries; import org.jabref.gui.undo.UndoableRemoveEntries; diff --git a/src/main/java/org/jabref/gui/edit/EditAction.java b/src/main/java/org/jabref/gui/edit/EditAction.java index 08f8663a99a..be8472a1585 100644 --- a/src/main/java/org/jabref/gui/edit/EditAction.java +++ b/src/main/java/org/jabref/gui/edit/EditAction.java @@ -7,11 +7,11 @@ import javafx.scene.control.TextInputControl; import javafx.scene.web.WebView; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; -import org.jabref.gui.library.LibraryTab; import org.fxmisc.richtext.CodeArea; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java b/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java index 086a3f5c119..8339b5db7f3 100644 --- a/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java +++ b/src/main/java/org/jabref/gui/edit/ReplaceStringAction.java @@ -3,10 +3,10 @@ import java.util.function.Supplier; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; public class ReplaceStringAction extends SimpleCommand { private final Supplier tabSupplier; diff --git a/src/main/java/org/jabref/gui/edit/ReplaceStringView.java b/src/main/java/org/jabref/gui/edit/ReplaceStringView.java index 9eb70981e27..a931406c99c 100644 --- a/src/main/java/org/jabref/gui/edit/ReplaceStringView.java +++ b/src/main/java/org/jabref/gui/edit/ReplaceStringView.java @@ -6,7 +6,7 @@ import javafx.scene.control.RadioButton; import javafx.scene.control.TextField; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.IconValidationDecorator; diff --git a/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java b/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java index 0787c418f8c..04db4bf9147 100644 --- a/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java +++ b/src/main/java/org/jabref/gui/edit/ReplaceStringViewModel.java @@ -9,7 +9,7 @@ import javafx.beans.property.StringProperty; import org.jabref.gui.AbstractViewModel; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java b/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java index 0993c00bdba..4fc8b9d8b63 100644 --- a/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java +++ b/src/main/java/org/jabref/gui/edit/automaticfiededitor/NotificationPaneAdapter.java @@ -5,8 +5,8 @@ import javafx.scene.Node; import javafx.util.Duration; +import org.jabref.gui.LibraryTab; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.library.LibraryTab; public class NotificationPaneAdapter extends LibraryTab.DatabaseNotification { diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 68b2044b40a..7ee6f1b6968 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -27,6 +27,7 @@ import javafx.scene.layout.BorderPane; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.citationkeypattern.GenerateCitationKeySingleAction; import org.jabref.gui.cleanup.CleanupSingleAction; @@ -38,7 +39,6 @@ import org.jabref.gui.importer.GrobidOptInDialogHelper; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.menus.ChangeEntryTypeMenu; import org.jabref.gui.mergeentries.FetchAndMergeEntry; import org.jabref.gui.theme.ThemeManager; diff --git a/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java b/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java index 6ffebb79cc1..36758215401 100644 --- a/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java +++ b/src/main/java/org/jabref/gui/entryeditor/OpenEntryEditorAction.java @@ -2,10 +2,10 @@ import java.util.function.Supplier; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; public class OpenEntryEditorAction extends SimpleCommand { diff --git a/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java b/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java index bd4dc6b915e..aa98a5b7e24 100644 --- a/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java +++ b/src/main/java/org/jabref/gui/entryeditor/PreviewSwitchAction.java @@ -2,9 +2,9 @@ import java.util.function.Supplier; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import static org.jabref.gui.actions.ActionHelper.needsDatabase; diff --git a/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java b/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java index 69a8f49eb63..01e2249d1b0 100644 --- a/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java @@ -26,6 +26,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.entryeditor.EntryEditorPreferences; import org.jabref.gui.entryeditor.EntryEditorTab; @@ -33,7 +34,6 @@ import org.jabref.gui.entryeditor.citationrelationtab.semanticscholar.SemanticScholarFetcher; import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.NoSelectionModel; import org.jabref.gui.util.ViewModelListCellFactory; diff --git a/src/main/java/org/jabref/gui/exporter/ExportCommand.java b/src/main/java/org/jabref/gui/exporter/ExportCommand.java index 107fe2f69dd..ccf81b353ff 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportCommand.java +++ b/src/main/java/org/jabref/gui/exporter/ExportCommand.java @@ -12,12 +12,12 @@ import javafx.util.Duration; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.gui.util.FileFilterConverter; diff --git a/src/main/java/org/jabref/gui/exporter/SaveAction.java b/src/main/java/org/jabref/gui/exporter/SaveAction.java index ce523eedc9c..d4fe785f229 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveAction.java @@ -4,10 +4,10 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.preferences.PreferencesService; /** diff --git a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java index 7270e33c66c..173de40ed0b 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java @@ -5,8 +5,8 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; +import org.jabref.gui.LibraryTab; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.logic.l10n.Localization; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java index 07760a7bf79..87cb097b734 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java @@ -19,9 +19,9 @@ import javafx.scene.text.Text; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.autosaveandbackup.AutosaveManager; import org.jabref.gui.autosaveandbackup.BackupManager; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java index 9d07dcf527c..22e520231b7 100644 --- a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java +++ b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java @@ -3,10 +3,10 @@ import java.util.Optional; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.externalfiles.ImportHandler; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.importer.CompositeIdFetcher; diff --git a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java index 44467fb06aa..e1a1c7cfc26 100644 --- a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java +++ b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdDialog.java @@ -6,9 +6,9 @@ import javafx.scene.control.TextField; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; import org.jabref.model.util.FileUpdateMonitor; diff --git a/src/main/java/org/jabref/gui/importer/NewEntryAction.java b/src/main/java/org/jabref/gui/importer/NewEntryAction.java index 36f92ba17d2..4737211f7fb 100644 --- a/src/main/java/org/jabref/gui/importer/NewEntryAction.java +++ b/src/main/java/org/jabref/gui/importer/NewEntryAction.java @@ -7,11 +7,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.EntryTypeView; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.Telemetry; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.types.EntryType; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java index 9f5054d5eef..56da949dcc6 100644 --- a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java @@ -6,7 +6,6 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; import org.jabref.gui.importer.ImportCustomEntryTypesDialog; -import org.jabref.gui.library.LibraryTab; import org.jabref.logic.importer.ParserResult; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntryType; diff --git a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java index a7cecd4e3c4..af295f03a19 100644 --- a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java @@ -14,13 +14,13 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.Telemetry; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.autosaveandbackup.BackupManager; import org.jabref.gui.dialogs.BackupUIManager; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.shared.SharedDatabaseUIManager; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java index 11e16943d5d..472efce865e 100644 --- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java +++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java @@ -8,9 +8,9 @@ import javafx.concurrent.Task; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.integrity.IntegrityCheck; import org.jabref.logic.integrity.IntegrityMessage; diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java index e11c4c3736a..368951a4bc3 100644 --- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java +++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java @@ -13,7 +13,7 @@ import javafx.scene.input.MouseButton; import javafx.stage.Modality; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.gui.theme.ThemeManager; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ValueTableCellFactory; diff --git a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java index db92a15c0ec..c876418fc4e 100644 --- a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java +++ b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java @@ -13,11 +13,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; import org.jabref.gui.JabRefExecutorService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; diff --git a/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java b/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java index 1d906f7b7ba..8dad9f0399c 100644 --- a/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java +++ b/src/main/java/org/jabref/gui/linkedfile/AttachFileAction.java @@ -4,11 +4,11 @@ import java.util.Optional; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.fieldeditors.LinkedFilesEditorViewModel; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index fd7142eaad7..439146b78a6 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -28,6 +28,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.DragAndDropDataFormats; import org.jabref.gui.Globals; +import org.jabref.gui.LibraryTab; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.actions.StandardActions; @@ -35,7 +36,6 @@ import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.maintable.columns.LibraryColumn; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.gui.util.ControlHelper; diff --git a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java index 79c7171a673..6e65da6ab13 100644 --- a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java +++ b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java @@ -8,6 +8,7 @@ import org.jabref.gui.ClipBoardManager; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.SendAsKindleEmailAction; import org.jabref.gui.SendAsStandardEmailAction; import org.jabref.gui.StateManager; @@ -17,7 +18,6 @@ import org.jabref.gui.edit.EditAction; import org.jabref.gui.exporter.ExportToClipboardAction; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.linkedfile.AttachFileAction; import org.jabref.gui.linkedfile.AttachFileFromURLAction; import org.jabref.gui.menus.ChangeEntryTypeMenu; diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index b70fcb02e8d..9e8b49e7d6a 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -28,6 +28,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.JabRefGUI; +import org.jabref.gui.LibraryTab; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionFactory; @@ -35,7 +36,6 @@ import org.jabref.gui.help.HelpAction; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableKeyChange; import org.jabref.gui.util.BackgroundTask; diff --git a/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java b/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java index 2622a8994f1..4fb2a575ab6 100644 --- a/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java +++ b/src/main/java/org/jabref/gui/search/RebuildFulltextSearchIndexAction.java @@ -3,9 +3,9 @@ import java.io.IOException; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java index 95393eed2ef..6505d7ca028 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java @@ -24,11 +24,11 @@ import org.jabref.gui.AbstractViewModel; import org.jabref.gui.DialogService; import org.jabref.gui.Globals; +import org.jabref.gui.LibraryTab; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.exporter.SaveDatabaseAction; import org.jabref.gui.help.HelpAction; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.gui.util.FileFilterConverter; import org.jabref.gui.util.TaskExecutor; diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java index 01f27e8bef6..387b165f158 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java @@ -12,11 +12,11 @@ import javafx.scene.control.ButtonType; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.entryeditor.EntryEditor; import org.jabref.gui.exporter.SaveDatabaseAction; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.mergeentries.EntriesMergeResult; import org.jabref.gui.mergeentries.MergeEntriesDialog; import org.jabref.gui.undo.UndoableRemoveEntries; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java index 241305aac05..fc256c69b56 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java @@ -9,10 +9,10 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.logic.l10n.Localization; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java index 9ecd1a733b2..47ec0ac27e4 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java @@ -9,9 +9,9 @@ import javafx.scene.control.MenuItem; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionFactory; -import org.jabref.gui.library.LibraryTab; import org.jabref.model.entry.field.SpecialField; import org.jabref.model.entry.field.SpecialFieldValue; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java index ba614ef0c60..ddda94ea1c6 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java @@ -9,11 +9,11 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.Action; import org.jabref.gui.actions.StandardActions; import org.jabref.gui.icon.JabRefIcon; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.logic.util.UpdateField; import org.jabref.model.FieldChange; diff --git a/src/main/java/org/jabref/gui/undo/UndoRedoAction.java b/src/main/java/org/jabref/gui/undo/UndoRedoAction.java index 319c5872c51..53b68628221 100644 --- a/src/main/java/org/jabref/gui/undo/UndoRedoAction.java +++ b/src/main/java/org/jabref/gui/undo/UndoRedoAction.java @@ -6,11 +6,11 @@ import javax.swing.undo.CannotUndoException; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; -import org.jabref.gui.library.LibraryTab; import org.jabref.logic.l10n.Localization; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java b/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java index 9dbd1d67608..e2e1c0f5b7e 100644 --- a/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java +++ b/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java @@ -11,7 +11,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; diff --git a/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java b/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java index 8e02ea6de28..d10a6c0221a 100644 --- a/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java +++ b/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java @@ -10,7 +10,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.logic.util.StandardFileType; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; diff --git a/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java b/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java index 51daa239d34..2fd7e54e5b0 100644 --- a/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java +++ b/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Objects; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.pdf.search.EnglishStemAnalyzer; import org.jabref.model.pdf.search.PdfSearchResults; diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index 85b46cbf7dd..12d67a71a2f 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -9,7 +9,7 @@ import java.util.stream.Collectors; import org.jabref.architecture.AllowedToUseLogic; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.logic.crawler.Crawler; import org.jabref.logic.crawler.StudyRepository; import org.jabref.logic.shared.DatabaseLocation; diff --git a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java index 57a34bcd918..a1ee0b8031e 100644 --- a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java +++ b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerDiscardedTest.java @@ -6,7 +6,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.logic.exporter.AtomicFileWriter; import org.jabref.logic.exporter.BibDatabaseWriter; import org.jabref.logic.exporter.BibWriter; diff --git a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java index 4c6181296c7..e34ac325b17 100644 --- a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java +++ b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Optional; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.logic.util.BackupFileType; import org.jabref.logic.util.OS; import org.jabref.logic.util.io.BackupFileUtil; diff --git a/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java b/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java index a7f884bd980..758e3a8241b 100644 --- a/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java +++ b/src/test/java/org/jabref/gui/edit/ReplaceStringViewModelTest.java @@ -6,7 +6,7 @@ import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java index 68f0d0331ae..9b36a5a712b 100644 --- a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java +++ b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java @@ -11,8 +11,7 @@ import javafx.collections.FXCollections; import org.jabref.gui.DialogService; -import org.jabref.gui.JabRefFrame; -import org.jabref.gui.library.LibraryTab; +import org.jabref.gui.LibraryTab; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.bibtex.FieldPreferences; diff --git a/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java b/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java index c0aab5170f3..12e36236576 100644 --- a/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java +++ b/src/test/java/org/jabref/gui/importer/NewEntryActionTest.java @@ -3,9 +3,9 @@ import java.util.List; import org.jabref.gui.DialogService; +import org.jabref.gui.LibraryTab; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; -import org.jabref.gui.library.LibraryTab; import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.types.EntryType; From 21ca8464f1bc1a4b1d24ebc728cf9b1a3cf0d5b6 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:41:34 +0100 Subject: [PATCH 11/18] Fixed quitting, removed unnecessary conversion between string and path --- src/main/java/org/jabref/gui/JabRefFrame.java | 36 ++++++++++--------- src/main/java/org/jabref/gui/JabRefGUI.java | 6 ++-- .../jabref/http/server/LibrariesResource.java | 1 - .../jabref/http/server/LibraryResource.java | 1 - .../java/org/jabref/http/server/Server.java | 21 +++++------ .../jabref/preferences/GuiPreferences.java | 8 ++--- .../jabref/preferences/JabRefPreferences.java | 11 ++++-- .../org/jabref/http/server/ServerTest.java | 4 +-- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 4c62476bfe0..e1ef090133a 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -352,16 +352,13 @@ public void about() { new HelpAction(HelpFile.CONTENTS, dialogService, prefs.getFilePreferences()).execute(); } - private void storeLastOpenedFiles(List filenames) { + private void storeLastOpenedFiles(List filenames, Path focusedDatabase) { if (prefs.getWorkspacePreferences().shouldOpenLastEdited()) { // Here we store the names of all current files. If there is no current file, we remove any // previously stored filename. if (filenames.isEmpty()) { prefs.getGuiPreferences().getLastFilesOpened().clear(); } else { - Path focusedDatabase = getCurrentLibraryTab().getBibDatabaseContext() - .getDatabasePath() - .orElse(null); prefs.getGuiPreferences().setLastFilesOpened(filenames); prefs.getGuiPreferences().setLastFocusedFile(focusedDatabase); } @@ -394,13 +391,15 @@ public boolean quit() { } } - List filenames = getLibraryTabs().stream() - .map(LibraryTab::getBibDatabaseContext) - .map(BibDatabaseContext::getDatabasePath) - .flatMap(Optional::stream) - .map(Path::toAbsolutePath) - .map(Path::toString) - .collect(Collectors.toList()); + // Read the opened and focused databases before closing them + List openedLibraries = getLibraryTabs().stream() + .map(LibraryTab::getBibDatabaseContext) + .map(BibDatabaseContext::getDatabasePath) + .flatMap(Optional::stream) + .collect(Collectors.toList()); + Path focusedLibraries = getCurrentLibraryTab().getBibDatabaseContext() + .getDatabasePath() + .orElse(null); // Then ask if the user really wants to close, if the library has not been saved since last save. if (!closeTabs()) { @@ -412,7 +411,8 @@ public boolean quit() { // We call saveWindow state here again because under Mac the windowClose listener on the stage isn't triggered when using cmd + q saveWindowState(); - storeLastOpenedFiles(filenames); + storeLastOpenedFiles(openedLibraries, focusedLibraries); // store only if successfully having closed the libraries + prefs.flush(); // Goodbye! @@ -761,9 +761,7 @@ public FileHistoryMenu getFileHistory() { } public boolean closeTab(LibraryTab libraryTab) { - Event requestCloseEvent = new Event(this, libraryTab, Tab.TAB_CLOSE_REQUEST_EVENT); - Event.fireEvent(libraryTab, requestCloseEvent); - if (!requestCloseEvent.isConsumed()) { + if (libraryTab.requestClose()) { Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); tabbedPane.getTabs().remove(libraryTab); return true; @@ -782,7 +780,7 @@ private boolean closeTabs() { // Close after checking for changes and saving all databases for (LibraryTab libraryTab : getLibraryTabs()) { Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); -// tabbedPane.getTabs().remove(libraryTab); + tabbedPane.getTabs().remove(libraryTab); } return true; } @@ -900,7 +898,11 @@ public CloseDatabaseAction(LibraryTabContainer tabContainer) { @Override public void execute() { - tabContainer.closeTab(libraryTab); + if (libraryTab == null) { + tabContainer.closeCurrentTab(); + } else { + tabContainer.closeTab(libraryTab); + } } } diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 134ff626773..3003f3f9022 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import javafx.application.Platform; import javafx.scene.Scene; @@ -320,13 +319,12 @@ private boolean isWindowPositionOutOfBounds() { } private void openLastEditedDatabases() { - List lastFiles = preferencesService.getGuiPreferences().getLastFilesOpened(); + List lastFiles = preferencesService.getGuiPreferences().getLastFilesOpened(); if (lastFiles.isEmpty()) { return; } - List filesToOpen = lastFiles.stream().map(Path::of).collect(Collectors.toList()); - getMainFrame().getOpenDatabaseAction().openFiles(filesToOpen); + getMainFrame().getOpenDatabaseAction().openFiles(lastFiles); } public static JabRefFrame getMainFrame() { diff --git a/src/main/java/org/jabref/http/server/LibrariesResource.java b/src/main/java/org/jabref/http/server/LibrariesResource.java index a5ea28c0ee1..8a178c031b2 100644 --- a/src/main/java/org/jabref/http/server/LibrariesResource.java +++ b/src/main/java/org/jabref/http/server/LibrariesResource.java @@ -21,7 +21,6 @@ public class LibrariesResource { @Produces(MediaType.APPLICATION_JSON) public String get() { List fileNamesWithUniqueSuffix = preferences.getGuiPreferences().getLastFilesOpened().stream() - .map(java.nio.file.Path::of) .map(p -> p.getFileName() + "-" + BackupFileUtil.getUniqueFilePrefix(p)) .toList(); return new Gson().toJson(fileNamesWithUniqueSuffix); diff --git a/src/main/java/org/jabref/http/server/LibraryResource.java b/src/main/java/org/jabref/http/server/LibraryResource.java index 2ff4b970723..d8f80e6e253 100644 --- a/src/main/java/org/jabref/http/server/LibraryResource.java +++ b/src/main/java/org/jabref/http/server/LibraryResource.java @@ -90,7 +90,6 @@ public Response getBibtex(@PathParam("id") String id) { private java.nio.file.Path getLibraryPath(String id) { return preferences.getGuiPreferences().getLastFilesOpened() .stream() - .map(java.nio.file.Path::of) .filter(p -> (p.getFileName() + "-" + BackupFileUtil.getUniqueFilePrefix(p)).equals(id)) .findAny() .orElseThrow(NotFoundException::new); diff --git a/src/main/java/org/jabref/http/server/Server.java b/src/main/java/org/jabref/http/server/Server.java index e238dceb577..a734031c585 100644 --- a/src/main/java/org/jabref/http/server/Server.java +++ b/src/main/java/org/jabref/http/server/Server.java @@ -5,7 +5,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; -import java.util.Collections; import java.util.List; import javax.net.ssl.SSLContext; @@ -37,26 +36,24 @@ public static void main(final String[] args) throws InterruptedException, URISyn SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); - final ObservableList lastFilesOpened = JabRefPreferences.getInstance().getGuiPreferences().getLastFilesOpened(); + final ObservableList lastFilesOpened = JabRefPreferences.getInstance().getGuiPreferences().getLastFilesOpened(); // The server serves the last opened files (see org.jabref.http.server.LibraryResource.getLibraryPath) // In a testing environment, this might be difficult to handle // This is a quick solution. The architectural fine solution would use some http context or other @Inject_ed variables in org.jabref.http.server.LibraryResource if (args.length > 0) { LOGGER.debug("Command line parameters passed"); - List filesToAdd = Arrays.stream(args) - .map(Path::of) - .filter(Files::exists) - .map(Path::toString) - .filter(path -> !lastFilesOpened.contains(path)) - .toList(); + List filesToAdd = Arrays.stream(args) + .map(Path::of) + .filter(Files::exists) + .filter(path -> !lastFilesOpened.contains(path)) + .toList(); LOGGER.debug("Adding following files to the list of opened libraries: {}", filesToAdd); // add the files in the front of the last opened libraries - Collections.reverse(filesToAdd); - for (String path : filesToAdd) { - lastFilesOpened.add(0, path); + for (Path path : filesToAdd.reversed()) { + lastFilesOpened.addFirst(path); } } @@ -66,7 +63,7 @@ public static void main(final String[] args) throws InterruptedException, URISyn // Path bibPath = Path.of(Server.class.getResource("http-server-demo.bib").toURI()); Path bibPath = Path.of("src/main/resources/org/jabref/http/server/http-server-demo.bib").toAbsolutePath(); LOGGER.debug("Location of demo library: {}", bibPath); - lastFilesOpened.add(bibPath.toString()); + lastFilesOpened.add(bibPath); } LOGGER.debug("Libraries served: {}", lastFilesOpened); diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index 479889efdc0..55c7ad95732 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -27,7 +27,7 @@ public class GuiPreferences { private final BooleanProperty windowFullScreen; // the last libraries that were open when jabref closes and should be reopened on startup - private final ObservableList lastFilesOpened; + private final ObservableList lastFilesOpened; private final ObjectProperty lastFocusedFile; // observable list last files opened in the file menu private final FileHistory fileHistory; @@ -46,7 +46,7 @@ public GuiPreferences(double positionX, double sizeY, boolean windowMaximised, boolean windowFullScreen, - List lastFilesOpened, + List lastFilesOpened, Path lastFocusedFile, FileHistory fileHistory, String lastSelectedIdBasedFetcher, @@ -147,11 +147,11 @@ public boolean isWindowFullscreen() { return windowFullScreen.get(); } - public ObservableList getLastFilesOpened() { + public ObservableList getLastFilesOpened() { return lastFilesOpened; } - public void setLastFilesOpened(List files) { + public void setLastFilesOpened(List files) { lastFilesOpened.setAll(files); } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 65b320e5971..f1d5794f5ce 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -2582,7 +2582,9 @@ public GuiPreferences getGuiPreferences() { getDouble(SIZE_Y), getBoolean(WINDOW_MAXIMISED), getBoolean(WINDOW_FULLSCREEN), - getStringList(LAST_EDITED), + getStringList(LAST_EDITED).stream() + .map(Path::of) + .collect(Collectors.toList()), Path.of(get(LAST_FOCUSED)), getFileHistory(), get(ID_ENTRY_GENERATOR), @@ -2599,11 +2601,14 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.sizeYProperty(), (obs, oldValue, newValue) -> putDouble(SIZE_Y, newValue.doubleValue())); EasyBind.listen(guiPreferences.windowMaximisedProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_MAXIMISED, newValue)); EasyBind.listen(guiPreferences.windowFullScreenProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_FULLSCREEN, newValue)); - guiPreferences.getLastFilesOpened().addListener((ListChangeListener) change -> { + guiPreferences.getLastFilesOpened().addListener((ListChangeListener) change -> { if (change.getList().isEmpty()) { prefs.remove(LAST_EDITED); } else { - putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened()); + putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened().stream() + .map(Path::toAbsolutePath) + .map(Path::toString) + .collect(Collectors.toList())); } }); EasyBind.listen(guiPreferences.lastFocusedFileProperty(), (obs, oldValue, newValue) -> { diff --git a/src/test/java/org/jabref/http/server/ServerTest.java b/src/test/java/org/jabref/http/server/ServerTest.java index 657a340e7c3..099c9fd88b0 100644 --- a/src/test/java/org/jabref/http/server/ServerTest.java +++ b/src/test/java/org/jabref/http/server/ServerTest.java @@ -67,7 +67,7 @@ protected void setAvailableLibraries(EnumSet files) { when(guiPreferences.getLastFilesOpened()).thenReturn( FXCollections.observableArrayList( files.stream() - .map(file -> file.path.toString()) + .map(file -> file.path) .collect(Collectors.toList()))); } @@ -93,6 +93,6 @@ private static void initializePreferencesService() { guiPreferences = mock(GuiPreferences.class); when(preferencesService.getGuiPreferences()).thenReturn(guiPreferences); - when(guiPreferences.getLastFilesOpened()).thenReturn(FXCollections.observableArrayList(TestBibFile.GENERAL_SERVER_TEST.path.toString())); + when(guiPreferences.getLastFilesOpened()).thenReturn(FXCollections.observableArrayList(TestBibFile.GENERAL_SERVER_TEST.path)); } } From 98b2d2c1997b7d4595db036e191f2e6f71912973 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:46:55 +0100 Subject: [PATCH 12/18] Reduced scope of UpdateTimestampListener again --- src/main/java/org/jabref/gui/UpdateTimestampListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/UpdateTimestampListener.java b/src/main/java/org/jabref/gui/UpdateTimestampListener.java index a4fa13f7e62..2ccc4a72d3c 100644 --- a/src/main/java/org/jabref/gui/UpdateTimestampListener.java +++ b/src/main/java/org/jabref/gui/UpdateTimestampListener.java @@ -10,10 +10,10 @@ /** * Updates the timestamp of changed entries if the feature is enabled */ -public class UpdateTimestampListener { +class UpdateTimestampListener { private final PreferencesService preferencesService; - public UpdateTimestampListener(PreferencesService preferencesService) { + UpdateTimestampListener(PreferencesService preferencesService) { this.preferencesService = preferencesService; } From 5b4823f6e58a4fb77422269c784e986a262d2912 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Wed, 10 Jan 2024 00:27:32 +0100 Subject: [PATCH 13/18] Reduced scope of some methods and fixed concurrency issue after prefs changes --- src/main/java/org/jabref/gui/JabRefFrame.java | 19 +++---------------- src/main/java/org/jabref/gui/LibraryTab.java | 18 +++++------------- .../preferences/ShowPreferencesAction.java | 2 +- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index e1ef090133a..20d9aa1d54e 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -648,19 +648,6 @@ public LibraryTab getCurrentLibraryTab() { return (LibraryTab) tabbedPane.getSelectionModel().getSelectedItem(); } - /** - * This method causes all open LibraryTabs to set up their tables anew. When called from PreferencesDialogViewModel, - * this updates to the new settings. We need to notify all tabs about the changes to avoid problems when changing - * the column set. - */ - public void setupAllTables() { - tabbedPane.getTabs().forEach(tab -> { - if (tab instanceof LibraryTab libraryTab && (libraryTab.getDatabase() != null)) { - DefaultTaskExecutor.runInJavaFXThread(libraryTab::setupMainPanel); - } - }); - } - private ContextMenu createTabContextMenuFor(LibraryTab tab, KeyBindingRepository keyBindingRepository) { ContextMenu contextMenu = new ContextMenu(); ActionFactory factory = new ActionFactory(keyBindingRepository); @@ -856,10 +843,10 @@ public Stage getMainStage() { /** * Refreshes the ui after preferences changes */ - public void refresh() { + public void refresh() { globalSearchBar.updateHintVisibility(); - setupAllTables(); - getLibraryTabs().forEach(panel -> panel.getMainTable().getTableModel().resetFieldFormatter()); + getLibraryTabs().forEach(LibraryTab::setupMainPanel); + getLibraryTabs().forEach(tab -> tab.getMainTable().getTableModel().resetFieldFormatter()); } /** diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index ace950d8c0f..c2088824944 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -218,7 +218,7 @@ private void setDataLoadingTask(BackgroundTask dataLoadingTask) { /** * The layout to display in the tab when it's loading */ - public Node createLoadingAnimationLayout() { + private Node createLoadingAnimationLayout() { ProgressIndicator progressIndicator = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); BorderPane pane = new BorderPane(); pane.setCenter(progressIndicator); @@ -226,13 +226,13 @@ public Node createLoadingAnimationLayout() { return pane; } - public void onDatabaseLoadingStarted() { + private void onDatabaseLoadingStarted() { Node loadingLayout = createLoadingAnimationLayout(); getMainTable().placeholderProperty().setValue(loadingLayout); tabContainer.addTab(this, true); } - public void onDatabaseLoadingSucceed(ParserResult result) { + private void onDatabaseLoadingSucceed(ParserResult result) { BibDatabaseContext context = result.getDatabaseContext(); OpenDatabaseAction.performPostOpenActions(result, dialogService); @@ -249,14 +249,14 @@ public void onDatabaseLoadingSucceed(ParserResult result) { dataLoadingTask = null; } - public void onDatabaseLoadingFailed(Exception ex) { + private void onDatabaseLoadingFailed(Exception ex) { String title = Localization.lang("Connection error"); String content = String.format("%s\n\n%s", ex.getMessage(), Localization.lang("A local copy will be opened.")); dialogService.showErrorDialogAndWait(title, content, ex); } - public void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { + private void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { if (this.getTabPane().getSelectionModel().selectedItemProperty().get().equals(this)) { // If you open an existing library, a library tab with a loading animation is added immediately. // At that point, the library tab is given a temporary bibDatabaseContext with no entries. @@ -858,10 +858,6 @@ public void cut() { mainTable.cut(); } - public BooleanProperty changedProperty() { - return changedProperty; - } - public boolean isModified() { return changedProperty.getValue(); } @@ -870,10 +866,6 @@ public void markBaseChanged() { this.changedProperty.setValue(true); } - public BooleanProperty nonUndoableChangeProperty() { - return nonUndoableChangeProperty; - } - public void markNonUndoableBaseChanged() { this.nonUndoableChangeProperty.setValue(true); this.changedProperty.setValue(true); diff --git a/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java b/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java index ca1d59c6f8a..0ba021be858 100644 --- a/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java +++ b/src/main/java/org/jabref/gui/preferences/ShowPreferencesAction.java @@ -23,7 +23,7 @@ public ShowPreferencesAction(LibraryTabContainer tabContainer, Class Date: Wed, 10 Jan 2024 01:23:58 +0100 Subject: [PATCH 14/18] Fixed test --- .../org/jabref/gui/autosaveandbackup/BackupManagerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java index e34ac325b17..349bfd2f5c3 100644 --- a/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java +++ b/src/test/java/org/jabref/gui/autosaveandbackup/BackupManagerTest.java @@ -150,7 +150,7 @@ public void shouldNotCreateABackup(@TempDir Path customDir) throws Exception { preferences); manager.listen(new MetaDataChangedEvent(new MetaData())); - BackupManager.shutdown(database, filePreferences); + BackupManager.shutdown(database, filePreferences.getBackupDirectory(), filePreferences.shouldCreateBackup()); List files = Files.list(backupDir).toList(); assertEquals(Collections.emptyList(), files); From 6e00c6ff48d88b7d27232b699ecca8a3d27044f4 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Wed, 10 Jan 2024 01:24:45 +0100 Subject: [PATCH 15/18] Fixed localization issue --- src/main/java/org/jabref/gui/LibraryTab.java | 28 ++++++++++--------- .../java/org/jabref/gui/edit/EditAction.java | 2 +- .../org/jabref/gui/maintable/MainTable.java | 6 ++-- src/main/resources/l10n/JabRef_en.properties | 8 ++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index c2088824944..635e4b1df6c 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -29,6 +29,7 @@ import javafx.scene.layout.BorderPane; import javafx.util.Duration; +import org.jabref.gui.actions.StandardActions; import org.jabref.gui.autocompleter.AutoCompletePreferences; import org.jabref.gui.autocompleter.PersonNameSuggestionProvider; import org.jabref.gui.autocompleter.SuggestionProvider; @@ -415,38 +416,43 @@ public SuggestionProviders getSuggestionProviders() { /** * Removes the selected entries from the database * - * @param cut If false the user will get asked if he really wants to delete the entries, and it will be localized as "deleted". If true the action will be localized as "cut" + * @param mode If DELETE_ENTRY the user will get asked if he really wants to delete the entries, and it will be localized as "deleted". If true the action will be localized as "cut" */ - public void delete(boolean cut) { - delete(cut, mainTable.getSelectedEntries()); + public void delete(StandardActions mode) { + delete(mode, mainTable.getSelectedEntries()); } /** * Removes the selected entries from the database * - * @param cut If false the user will get asked if he really wants to delete the entries, and it will be localized as "deleted". If true the action will be localized as "cut" + * @param mode If DELETE_ENTRY the user will get asked if he really wants to delete the entries, and it will be localized as "deleted". If true the action will be localized as "cut" */ - private void delete(boolean cut, List entries) { + private void delete(StandardActions mode, List entries) { if (entries.isEmpty()) { return; } - if (!cut && !showDeleteConfirmationDialog(entries.size())) { + if (mode == StandardActions.DELETE_ENTRY && !showDeleteConfirmationDialog(entries.size())) { return; } - getUndoManager().addEdit(new UndoableRemoveEntries(bibDatabaseContext.getDatabase(), entries, cut)); + getUndoManager().addEdit(new UndoableRemoveEntries(bibDatabaseContext.getDatabase(), entries, mode == StandardActions.CUT)); bibDatabaseContext.getDatabase().removeEntries(entries); ensureNotShowingBottomPanel(entries); this.changedProperty.setValue(true); - dialogService.notify(formatOutputMessage(cut ? Localization.lang("Cut") : Localization.lang("Deleted"), entries.size())); + switch (mode) { + case StandardActions.CUT -> + dialogService.notify(Localization.lang("Cut %0 entry(ies)", entries.size())); + case StandardActions.DELETE_ENTRY -> + dialogService.notify(Localization.lang("Deleted %0 entry(ies)", entries.size())); + } // prevent the main table from loosing focus mainTable.requestFocus(); } public void delete(BibEntry entry) { - delete(false, Collections.singletonList(entry)); + delete(StandardActions.DELETE_ENTRY, Collections.singletonList(entry)); } public void registerUndoableChanges(List changes) { @@ -801,10 +807,6 @@ public void setSaving(boolean saving) { this.saving = saving; } - public String formatOutputMessage(String start, int count) { - return String.format("%s %d %s.", start, count, (count > 1 ? Localization.lang("entries") : Localization.lang("entry"))); - } - public CountingUndoManager getUndoManager() { return undoManager; } diff --git a/src/main/java/org/jabref/gui/edit/EditAction.java b/src/main/java/org/jabref/gui/edit/EditAction.java index be8472a1585..2c870a821cb 100644 --- a/src/main/java/org/jabref/gui/edit/EditAction.java +++ b/src/main/java/org/jabref/gui/edit/EditAction.java @@ -81,7 +81,7 @@ public void execute() { case COPY -> tabSupplier.get().copy(); case CUT -> tabSupplier.get().cut(); case PASTE -> tabSupplier.get().paste(); - case DELETE_ENTRY -> tabSupplier.get().delete(false); + case DELETE_ENTRY -> tabSupplier.get().delete(StandardActions.DELETE_ENTRY); case UNDO -> { if (undoManager.canUndo()) { undoManager.undo(); diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 439146b78a6..21fac134607 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -255,16 +255,16 @@ public void copy() { if (!selectedEntries.isEmpty()) { try { clipBoardManager.setContent(selectedEntries, entryTypesManager); - dialogService.notify(libraryTab.formatOutputMessage(Localization.lang("Copied"), selectedEntries.size())); + dialogService.notify(Localization.lang("Copied %0 entry(ies)", selectedEntries.size())); } catch (IOException e) { - LOGGER.error("Error while copying selected entries to clipboard", e); + LOGGER.error("Error while copying selected entries to clipboard.", e); } } } public void cut() { copy(); - libraryTab.delete(true); + libraryTab.delete(StandardActions.CUT); } private void setupKeyBindings(KeyBindingRepository keyBindings) { diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index e9edd71f8d8..d2a0bc3350c 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -164,9 +164,6 @@ Contained\ in=Contained in Content=Content -Copied=Copied - - Copy=Copy Copy\ title=Copy title @@ -235,8 +232,6 @@ Delete\ entry=Delete entry Delete\ multiple\ entries=Delete multiple entries -Deleted=Deleted - Permanently\ delete\ local\ file=Permanently delete local file Descending=Descending @@ -2623,6 +2618,9 @@ Pushing\ citations\ to\ TeXShop\ is\ only\ possible\ on\ macOS\!=Pushing citatio Single\ instance=Single instance Enforce\ single\ JabRef\ instance\ (and\ allow\ remote\ operations)\ using\ port=Enforce single JabRef instance (and allow remote operations) using port +Copied\ %0\ entry(ies)=Copied %0 entry(ies) +Cut\ %0\ entry(ies)=Cut %0 entry(ies) +Deleted\ %0\ entry(ies)=Deleted %0 entry(ies) Enable\ Journal\ Information\ Fetching?=Enable Journal Information Fetching? Would\ you\ like\ to\ enable\ fetching\ of\ journal\ information?\ This\ can\ be\ changed\ later\ in\ %0\ >\ %1.=Would you like to enable fetching of journal information? This can be changed later in %0 > %1. From 678f8290a36a5417d9a06e742635f5473db7ce79 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Wed, 10 Jan 2024 01:42:25 +0100 Subject: [PATCH 16/18] Fixed merge errors --- src/main/java/org/jabref/gui/LibraryTab.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index 138b61bcc15..422f8e48895 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -781,6 +781,7 @@ private void onCloseRequest(Event event) { */ private void onClosed(Event event) { changeMonitor.ifPresent(DatabaseChangeMonitor::unregister); + PdfIndexerManager.shutdownIndexer(bibDatabaseContext); AutosaveManager.shutdown(bibDatabaseContext); BackupManager.shutdown(bibDatabaseContext, preferencesService.getFilePreferences().getBackupDirectory(), From 9840953509da13e02daefe131d67bd1d59b2d06b Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Wed, 10 Jan 2024 22:06:28 +0100 Subject: [PATCH 17/18] Fixed review comments --- src/main/java/org/jabref/gui/JabRefFrame.java | 4 ++-- src/main/java/org/jabref/gui/LibraryTab.java | 19 +++++++++++-------- .../org/jabref/gui/LibraryTabContainer.java | 13 ++++++++++++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 20d9aa1d54e..f18d0e1ade1 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -772,8 +772,8 @@ private boolean closeTabs() { return true; } - public void closeCurrentTab() { - closeTab(getCurrentLibraryTab()); + public boolean closeCurrentTab() { + return closeTab(getCurrentLibraryTab()); } public OpenDatabaseAction getOpenDatabaseAction() { diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index 422f8e48895..fbd701e5057 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -90,12 +90,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Represents the ui area where the notifier pane, the library table and the entry editor are shown. + */ public class LibraryTab extends Tab { /** - * Defines the different modes that the BasePanel can operate in + * Defines the different modes that the tab can operate in */ - private enum PanelMode { TABLE, TABLE_EDITOR } + private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR } private static final Logger LOGGER = LoggerFactory.getLogger(LibraryTab.class); private final LibraryTabContainer tabContainer; @@ -114,7 +117,7 @@ private enum PanelMode { TABLE, TABLE_EDITOR } private FileAnnotationCache annotationCache; private EntryEditor entryEditor; private MainTable mainTable; - private PanelMode mode = PanelMode.TABLE; + private PanelMode mode = PanelMode.MAIN_TABLE; private SplitPane splitPane; private DatabaseNotification databaseNotificationPane; private boolean saving; @@ -586,7 +589,7 @@ public EntryEditor getEntryEditor() { public void showAndEdit(BibEntry entry) { if (!splitPane.getItems().contains(entryEditor)) { splitPane.getItems().addLast(entryEditor); - mode = PanelMode.TABLE_EDITOR; + mode = PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR; splitPane.setDividerPositions(preferencesService.getEntryEditorPreferences().getDividerPosition()); } @@ -602,7 +605,7 @@ public void showAndEdit(BibEntry entry) { * Removes the bottom component. */ public void closeBottomPane() { - mode = PanelMode.TABLE; + mode = PanelMode.MAIN_TABLE; splitPane.getItems().remove(entryEditor); } @@ -635,13 +638,13 @@ public void entryEditorClosing() { private void ensureNotShowingBottomPanel(List entriesToCheck) { // This method is not able to close the bottom pane currently - if ((mode == PanelMode.TABLE_EDITOR) && (entriesToCheck.contains(entryEditor.getEntry()))) { + if ((mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) && (entriesToCheck.contains(entryEditor.getEntry()))) { closeBottomPane(); } } public void updateEntryEditorIfShowing() { - if (mode == PanelMode.TABLE_EDITOR) { + if (mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) { BibEntry currentEntry = entryEditor.getEntry(); showAndEdit(currentEntry); } @@ -691,7 +694,7 @@ private boolean showDeleteConfirmationDialog(int numberOfEntries) { * Depending on whether a preview or an entry editor is showing, save the current divider location in the correct preference setting. */ private void saveDividerLocation(Number position) { - if (mode == PanelMode.TABLE_EDITOR) { + if (mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) { preferencesService.getEntryEditorPreferences().setDividerPosition(position.doubleValue()); } } diff --git a/src/main/java/org/jabref/gui/LibraryTabContainer.java b/src/main/java/org/jabref/gui/LibraryTabContainer.java index 544644cdf52..a290676bd3a 100644 --- a/src/main/java/org/jabref/gui/LibraryTabContainer.java +++ b/src/main/java/org/jabref/gui/LibraryTabContainer.java @@ -15,9 +15,20 @@ public interface LibraryTabContainer { void addTab(BibDatabaseContext bibDatabaseContext, boolean raisePanel); + /** + * Closes a designated libraryTab + * + * @param libraryTab to be closed. + * @return true if closing the tab was successful + */ boolean closeTab(LibraryTab libraryTab); - void closeCurrentTab(); + /** + * Closes the currently viewed libraryTab + * + * @return true if closing the tab was successful + */ + boolean closeCurrentTab(); /** * Refreshes the ui after changes to the preferences From 374a9691c7738ec8ac699dda4c58c957c0a35f03 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Wed, 10 Jan 2024 22:57:25 +0100 Subject: [PATCH 18/18] Fixed small concurrency errors and nullptr --- src/main/java/org/jabref/gui/JabRefFrame.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index f18d0e1ade1..b67be5f66da 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -396,10 +396,11 @@ public boolean quit() { .map(LibraryTab::getBibDatabaseContext) .map(BibDatabaseContext::getDatabasePath) .flatMap(Optional::stream) - .collect(Collectors.toList()); - Path focusedLibraries = getCurrentLibraryTab().getBibDatabaseContext() - .getDatabasePath() - .orElse(null); + .toList(); + Path focusedLibraries = Optional.ofNullable(getCurrentLibraryTab()) + .map(LibraryTab::getBibDatabaseContext) + .flatMap(BibDatabaseContext::getDatabasePath) + .orElse(null); // Then ask if the user really wants to close, if the library has not been saved since last save. if (!closeTabs()) { @@ -749,8 +750,8 @@ public FileHistoryMenu getFileHistory() { public boolean closeTab(LibraryTab libraryTab) { if (libraryTab.requestClose()) { - Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); tabbedPane.getTabs().remove(libraryTab); + Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); return true; } return false; @@ -766,8 +767,8 @@ private boolean closeTabs() { // Close after checking for changes and saving all databases for (LibraryTab libraryTab : getLibraryTabs()) { - Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); tabbedPane.getTabs().remove(libraryTab); + Event.fireEvent(libraryTab, new Event(this, libraryTab, Tab.CLOSED_EVENT)); } return true; } @@ -885,11 +886,13 @@ public CloseDatabaseAction(LibraryTabContainer tabContainer) { @Override public void execute() { - if (libraryTab == null) { - tabContainer.closeCurrentTab(); - } else { - tabContainer.closeTab(libraryTab); - } + Platform.runLater(() -> { + if (libraryTab == null) { + tabContainer.closeCurrentTab(); + } else { + tabContainer.closeTab(libraryTab); + } + }); } } @@ -908,7 +911,7 @@ public void execute() { for (Tab tab : tabbedPane.getTabs()) { LibraryTab libraryTab = (LibraryTab) tab; if (libraryTab != toKeepLibraryTab) { - closeTab(libraryTab); + Platform.runLater(() -> closeTab(libraryTab)); } } } @@ -919,7 +922,7 @@ private class CloseAllDatabaseAction extends SimpleCommand { @Override public void execute() { for (Tab tab : tabbedPane.getTabs()) { - closeTab((LibraryTab) tab); + Platform.runLater(() -> closeTab((LibraryTab) tab)); } } }