From d9d596eac7fa0e00aea872303492e5e2e5fa52e3 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Sat, 7 Sep 2024 01:11:09 +0200 Subject: [PATCH 01/24] initial --- .../collab/DatabaseChangesResolverDialog.java | 3 +- .../entrychange/EntryChangeDetailsView.java | 3 +- .../jabref/gui/entryeditor/CommentsTab.java | 17 +--- .../gui/entryeditor/DeprecatedFieldsTab.java | 23 +++-- .../entryeditor/DetailOptionalFieldsTab.java | 13 +-- .../jabref/gui/entryeditor/EntryEditor.java | 30 ++++-- .../gui/entryeditor/FieldsEditorTab.java | 39 ++------ .../ImportantOptionalFieldsTab.java | 13 +-- .../entryeditor/OptionalFieldsTabBase.java | 13 +-- .../gui/entryeditor/OtherFieldsTab.java | 17 ++-- .../jabref/gui/entryeditor/PreviewTab.java | 30 +----- .../gui/entryeditor/RequiredFieldsTab.java | 24 +++-- .../gui/entryeditor/UserDefinedFieldsTab.java | 22 +++-- .../ExternalFilesEntryLinker.java | 16 +-- .../gui/externalfiles/ImportHandler.java | 2 +- .../gui/maintable/MainTableColumnFactory.java | 2 +- .../gui/maintable/MainTableTooltip.java | 7 +- .../gui/maintable/columns/FieldColumn.java | 2 +- .../gui/openoffice/StyleSelectDialogView.java | 3 +- .../gui/preferences/preview/PreviewTab.java | 3 +- .../org/jabref/gui/preview/PreviewPanel.java | 97 +++++++++++-------- .../org/jabref/gui/preview/PreviewViewer.java | 57 +++++------ .../gui/search/GlobalSearchResultDialog.java | 3 +- .../jabref/logic/cleanup/CleanupWorker.java | 6 +- .../logic/cleanup/MoveFilesCleanup.java | 7 +- .../logic/cleanup/RenamePdfCleanup.java | 7 +- .../gui/entryeditor/CommentsTabTest.java | 54 ++++++----- 27 files changed, 245 insertions(+), 268 deletions(-) diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java b/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java index 7da15d69823..175ee7682ce 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java @@ -99,7 +99,8 @@ public boolean areAllChangesDenied() { @FXML private void initialize() { - PreviewViewer previewViewer = new PreviewViewer(database, dialogService, preferencesService, themeManager, taskExecutor); + PreviewViewer previewViewer = new PreviewViewer(dialogService, preferencesService, themeManager, taskExecutor); + previewViewer.setDatabaseContext(database); DatabaseChangeDetailsViewFactory databaseChangeDetailsViewFactory = new DatabaseChangeDetailsViewFactory(database, dialogService, themeManager, preferencesService, entryTypesManager, previewViewer, taskExecutor); viewModel = new ExternalChangesResolverViewModel(changes, undoManager); diff --git a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java index 80e7762c49d..2422181545b 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java @@ -40,7 +40,8 @@ public EntryChangeDetailsView(BibEntry oldEntry, onDisk.getStyleClass().add("lib-change-header"); // we need a copy here as we otherwise would set the same entry twice - PreviewViewer previewClone = new PreviewViewer(databaseContext, dialogService, preferencesService, themeManager, taskExecutor); + PreviewViewer previewClone = new PreviewViewer(dialogService, preferencesService, themeManager, taskExecutor); + previewClone.setDatabaseContext(databaseContext); // The scroll bar used is not part of ScrollPane, but the attached WebView. WebView previewCloneView = (WebView) previewClone.getContent(); diff --git a/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java b/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java index 574c6908366..ce1773e6926 100644 --- a/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java @@ -21,20 +21,17 @@ import org.jabref.gui.fieldeditors.FieldEditorFX; import org.jabref.gui.fieldeditors.FieldNameLabel; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.theme.ThemeManager; +import org.jabref.gui.preview.PreviewPanel; import org.jabref.gui.undo.RedoAction; import org.jabref.gui.undo.UndoAction; -import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.l10n.Localization; -import org.jabref.logic.search.LuceneManager; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UserSpecificCommentField; -import org.jabref.model.search.SearchQuery; import org.jabref.preferences.PreferencesService; public class CommentsTab extends FieldsEditorTab { @@ -52,13 +49,10 @@ public CommentsTab(PreferencesService preferences, UndoAction undoAction, RedoAction redoAction, DialogService dialogService, - ThemeManager themeManager, TaskExecutor taskExecutor, JournalAbbreviationRepository journalAbbreviationRepository, - LuceneManager luceneManager, - OptionalObjectProperty searchQueryProperty) { - super( - false, + PreviewPanel previewPanel) { + super(false, databaseContext, suggestionProviders, undoManager, @@ -66,12 +60,9 @@ public CommentsTab(PreferencesService preferences, redoAction, dialogService, preferences, - themeManager, taskExecutor, journalAbbreviationRepository, - luceneManager, - searchQueryProperty - ); + previewPanel); this.defaultOwner = preferences.getOwnerPreferences().getDefaultOwner().toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9]", "-"); setText(Localization.lang("Comments")); setGraphic(IconTheme.JabRefIcons.COMMENT.getGraphicNode()); diff --git a/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java b/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java index 4341e7e76cd..00b49276c2a 100644 --- a/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java @@ -12,21 +12,18 @@ import org.jabref.gui.DialogService; import org.jabref.gui.autocompleter.SuggestionProviders; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.theme.ThemeManager; +import org.jabref.gui.preview.PreviewPanel; import org.jabref.gui.undo.RedoAction; import org.jabref.gui.undo.UndoAction; -import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.l10n.Localization; -import org.jabref.logic.search.LuceneManager; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibEntryType; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.entry.field.Field; -import org.jabref.model.search.SearchQuery; import org.jabref.preferences.PreferencesService; import com.tobiasdiez.easybind.EasyBind; @@ -43,13 +40,23 @@ public DeprecatedFieldsTab(BibDatabaseContext databaseContext, RedoAction redoAction, DialogService dialogService, PreferencesService preferences, - ThemeManager themeManager, BibEntryTypesManager entryTypesManager, TaskExecutor taskExecutor, JournalAbbreviationRepository journalAbbreviationRepository, - LuceneManager luceneManager, - OptionalObjectProperty searchQueryProperty) { - super(false, databaseContext, suggestionProviders, undoManager, undoAction, redoAction, dialogService, preferences, themeManager, taskExecutor, journalAbbreviationRepository, luceneManager, searchQueryProperty); + PreviewPanel previewPanel) { + super( + false, + databaseContext, + suggestionProviders, + undoManager, + undoAction, + redoAction, + dialogService, + preferences, + taskExecutor, + journalAbbreviationRepository, + previewPanel + ); this.entryTypesManager = entryTypesManager; setText(Localization.lang("Deprecated fields")); diff --git a/src/main/java/org/jabref/gui/entryeditor/DetailOptionalFieldsTab.java b/src/main/java/org/jabref/gui/entryeditor/DetailOptionalFieldsTab.java index 43097483626..70226284e07 100644 --- a/src/main/java/org/jabref/gui/entryeditor/DetailOptionalFieldsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/DetailOptionalFieldsTab.java @@ -4,17 +4,14 @@ import org.jabref.gui.DialogService; import org.jabref.gui.autocompleter.SuggestionProviders; -import org.jabref.gui.theme.ThemeManager; +import org.jabref.gui.preview.PreviewPanel; import org.jabref.gui.undo.RedoAction; import org.jabref.gui.undo.UndoAction; -import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.l10n.Localization; -import org.jabref.logic.search.LuceneManager; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntryTypesManager; -import org.jabref.model.search.SearchQuery; import org.jabref.preferences.PreferencesService; public class DetailOptionalFieldsTab extends OptionalFieldsTabBase { @@ -28,12 +25,10 @@ public DetailOptionalFieldsTab(BibDatabaseContext databaseContext, RedoAction redoAction, DialogService dialogService, PreferencesService preferences, - ThemeManager themeManager, BibEntryTypesManager entryTypesManager, TaskExecutor taskExecutor, JournalAbbreviationRepository journalAbbreviationRepository, - LuceneManager luceneManager, - OptionalObjectProperty searchQueryProperty) { + PreviewPanel previewPanel) { super( Localization.lang("Optional fields 2"), false, @@ -44,12 +39,10 @@ public DetailOptionalFieldsTab(BibDatabaseContext databaseContext, redoAction, dialogService, preferences, - themeManager, entryTypesManager, taskExecutor, journalAbbreviationRepository, - luceneManager, - searchQueryProperty + previewPanel ); } } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 67be8a5f908..f7ea4368a6b 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -42,6 +42,7 @@ import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.menus.ChangeEntryTypeMenu; import org.jabref.gui.mergeentries.FetchAndMergeEntry; +import org.jabref.gui.preview.PreviewPanel; import org.jabref.gui.theme.ThemeManager; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.undo.RedoAction; @@ -91,6 +92,7 @@ public class EntryEditor extends BorderPane { private final BibDatabaseContext databaseContext; private final EntryEditorPreferences entryEditorPreferences; private final ExternalFilesEntryLinker fileLinker; + private final PreviewPanel previewPanel; private final DirectoryMonitorManager directoryMonitorManager; private final UndoAction undoAction; private final RedoAction redoAction; @@ -136,7 +138,17 @@ public EntryEditor(LibraryTab libraryTab, UndoAction undoAction, RedoAction redo .load(); this.entryEditorPreferences = preferencesService.getEntryEditorPreferences(); - this.fileLinker = new ExternalFilesEntryLinker(preferencesService.getFilePreferences(), databaseContext, dialogService); + this.fileLinker = new ExternalFilesEntryLinker(preferencesService.getFilePreferences(), dialogService, stateManager); + this.previewPanel = new PreviewPanel( + dialogService, + preferencesService.getKeyBindingRepository(), + preferencesService, + themeManager, + taskExecutor, + libraryTab.getLuceneManager(), + stateManager, + libraryTab.searchQueryProperty()); + this.previewPanel.setDatabase(databaseContext); setupKeyBindings(); @@ -278,21 +290,21 @@ private void navigateToNextEntry() { private List createTabs() { List tabs = new LinkedList<>(); - tabs.add(new PreviewTab(databaseContext, dialogService, preferencesService, themeManager, taskExecutor, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); + tabs.add(new PreviewTab(databaseContext, preferencesService, previewPanel)); // Required, optional (important+detail), deprecated, and "other" fields - tabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); - tabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); - tabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); - tabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); - tabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); + tabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, previewPanel)); + tabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, previewPanel)); + tabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, previewPanel)); + tabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, previewPanel)); + tabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, previewPanel)); // Comment Tab: Tab for general and user-specific comments - tabs.add(new CommentsTab(preferencesService, databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, themeManager, taskExecutor, journalAbbreviationRepository, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); + tabs.add(new CommentsTab(preferencesService, databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, taskExecutor, journalAbbreviationRepository, previewPanel)); Map> entryEditorTabList = getAdditionalUserConfiguredTabs(); for (Map.Entry> tab : entryEditorTabList.entrySet()) { - tabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, taskExecutor, journalAbbreviationRepository, libraryTab.getLuceneManager(), libraryTab.searchQueryProperty())); + tabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, taskExecutor, journalAbbreviationRepository, previewPanel)); } tabs.add(new MathSciNetTab()); diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java index 13032495e00..bc2c03d3851 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java @@ -30,17 +30,13 @@ import org.jabref.gui.fieldeditors.FieldEditors; import org.jabref.gui.fieldeditors.FieldNameLabel; import org.jabref.gui.preview.PreviewPanel; -import org.jabref.gui.theme.ThemeManager; import org.jabref.gui.undo.RedoAction; import org.jabref.gui.undo.UndoAction; -import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.journals.JournalAbbreviationRepository; -import org.jabref.logic.search.LuceneManager; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; -import org.jabref.model.search.SearchQuery; import org.jabref.preferences.PreferencesService; import com.tobiasdiez.easybind.EasyBind; @@ -59,13 +55,10 @@ abstract class FieldsEditorTab extends EntryEditorTab implements OffersPreview { private final RedoAction redoAction; private final DialogService dialogService; private final PreferencesService preferences; - private final ThemeManager themeManager; private final TaskExecutor taskExecutor; private final JournalAbbreviationRepository journalAbbreviationRepository; - private PreviewPanel previewPanel; + private final PreviewPanel previewPanel; private final UndoManager undoManager; - private final LuceneManager luceneManager; - private final OptionalObjectProperty searchQueryProperty; private Collection fields = new ArrayList<>(); @SuppressWarnings("FieldCanBeLocal") private Subscription dividerPositionSubscription; @@ -78,11 +71,9 @@ public FieldsEditorTab(boolean compressed, RedoAction redoAction, DialogService dialogService, PreferencesService preferences, - ThemeManager themeManager, TaskExecutor taskExecutor, JournalAbbreviationRepository journalAbbreviationRepository, - LuceneManager luceneManager, - OptionalObjectProperty searchQueryProperty) { + PreviewPanel previewPanel) { this.isCompressed = compressed; this.databaseContext = Objects.requireNonNull(databaseContext); this.suggestionProviders = Objects.requireNonNull(suggestionProviders); @@ -91,11 +82,9 @@ public FieldsEditorTab(boolean compressed, this.redoAction = redoAction; this.dialogService = Objects.requireNonNull(dialogService); this.preferences = Objects.requireNonNull(preferences); - this.themeManager = themeManager; this.taskExecutor = Objects.requireNonNull(taskExecutor); this.journalAbbreviationRepository = Objects.requireNonNull(journalAbbreviationRepository); - this.luceneManager = luceneManager; - this.searchQueryProperty = searchQueryProperty; + this.previewPanel = previewPanel; } private static void addColumn(GridPane gridPane, int columnIndex, List