From 0cc39a18396a2d8e510e9e34eaee000d26a518f6 Mon Sep 17 00:00:00 2001 From: Loay Ghreeb Date: Thu, 15 Aug 2024 01:24:17 +0300 Subject: [PATCH 1/5] Update PreviewView to listen for library search queries --- .../DatabaseChangeDetailsViewFactory.java | 5 --- .../collab/DatabaseChangesResolverDialog.java | 6 +-- .../entrychange/EntryChangeDetailsView.java | 8 ++-- .../jabref/gui/entryeditor/CommentsTab.java | 11 +++--- .../gui/entryeditor/DeprecatedFieldsTab.java | 9 +++-- .../entryeditor/DetailOptionalFieldsTab.java | 11 +++--- .../jabref/gui/entryeditor/EntryEditor.java | 16 ++++---- .../gui/entryeditor/FieldsEditorTab.java | 16 ++++---- .../ImportantOptionalFieldsTab.java | 11 +++--- .../entryeditor/OptionalFieldsTabBase.java | 11 +++--- .../gui/entryeditor/OtherFieldsTab.java | 11 +++--- .../jabref/gui/entryeditor/PreviewTab.java | 13 ++++--- .../gui/entryeditor/RequiredFieldsTab.java | 9 +++-- .../gui/entryeditor/UserDefinedFieldsTab.java | 9 +++-- .../gui/maintable/MainTableColumnFactory.java | 2 +- .../gui/maintable/MainTableTooltip.java | 7 +--- .../gui/openoffice/StyleSelectDialogView.java | 7 +--- .../gui/preferences/preview/PreviewTab.java | 2 +- .../org/jabref/gui/preview/PreviewPanel.java | 13 +++---- .../org/jabref/gui/preview/PreviewViewer.java | 38 ++++++++++--------- .../gui/search/GlobalSearchResultDialog.java | 2 +- 21 files changed, 106 insertions(+), 111 deletions(-) diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsViewFactory.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsViewFactory.java index e20809388f0..41bee3ad227 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsViewFactory.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsViewFactory.java @@ -1,7 +1,6 @@ package org.jabref.gui.collab; import org.jabref.gui.DialogService; -import org.jabref.gui.StateManager; import org.jabref.gui.collab.entryadd.EntryAdd; import org.jabref.gui.collab.entrychange.EntryChange; import org.jabref.gui.collab.entrychange.EntryChangeDetailsView; @@ -31,7 +30,6 @@ public class DatabaseChangeDetailsViewFactory { private final BibDatabaseContext databaseContext; private final DialogService dialogService; - private final StateManager stateManager; private final ThemeManager themeManager; private final PreferencesService preferencesService; private final BibEntryTypesManager entryTypesManager; @@ -40,7 +38,6 @@ public class DatabaseChangeDetailsViewFactory { public DatabaseChangeDetailsViewFactory(BibDatabaseContext databaseContext, DialogService dialogService, - StateManager stateManager, ThemeManager themeManager, PreferencesService preferencesService, BibEntryTypesManager entryTypesManager, @@ -48,7 +45,6 @@ public DatabaseChangeDetailsViewFactory(BibDatabaseContext databaseContext, TaskExecutor taskExecutor) { this.databaseContext = databaseContext; this.dialogService = dialogService; - this.stateManager = stateManager; this.themeManager = themeManager; this.preferencesService = preferencesService; this.entryTypesManager = entryTypesManager; @@ -63,7 +59,6 @@ public DatabaseChangeDetailsView create(DatabaseChange databaseChange) { entryChange.getNewEntry(), databaseContext, dialogService, - stateManager, themeManager, preferencesService, entryTypesManager, diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java b/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java index 3feb8b95de1..7da15d69823 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangesResolverDialog.java @@ -15,7 +15,6 @@ import javafx.scene.layout.BorderPane; import org.jabref.gui.DialogService; -import org.jabref.gui.StateManager; import org.jabref.gui.preview.PreviewViewer; import org.jabref.gui.theme.ThemeManager; import org.jabref.gui.util.BaseDialog; @@ -57,7 +56,6 @@ public class DatabaseChangesResolverDialog extends BaseDialog { private boolean areAllChangesDenied; @Inject private UndoManager undoManager; - @Inject private StateManager stateManager; @Inject private DialogService dialogService; @Inject private PreferencesService preferencesService; @Inject private ThemeManager themeManager; @@ -101,8 +99,8 @@ public boolean areAllChangesDenied() { @FXML private void initialize() { - PreviewViewer previewViewer = new PreviewViewer(database, dialogService, preferencesService, stateManager, themeManager, taskExecutor); - DatabaseChangeDetailsViewFactory databaseChangeDetailsViewFactory = new DatabaseChangeDetailsViewFactory(database, dialogService, stateManager, themeManager, preferencesService, entryTypesManager, previewViewer, taskExecutor); + PreviewViewer previewViewer = new PreviewViewer(database, dialogService, preferencesService, themeManager, taskExecutor); + 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 f2722c5ee49..80e7762c49d 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java @@ -10,7 +10,6 @@ import javafx.scene.web.WebView; import org.jabref.gui.DialogService; -import org.jabref.gui.StateManager; import org.jabref.gui.collab.DatabaseChangeDetailsView; import org.jabref.gui.preview.PreviewViewer; import org.jabref.gui.theme.ThemeManager; @@ -24,15 +23,12 @@ import com.tobiasdiez.easybind.EasyBind; public final class EntryChangeDetailsView extends DatabaseChangeDetailsView { - private final PreviewWithSourceTab oldPreviewWithSourcesTab = new PreviewWithSourceTab(); - private final PreviewWithSourceTab newPreviewWithSourcesTab = new PreviewWithSourceTab(); private boolean scrolling = false; public EntryChangeDetailsView(BibEntry oldEntry, BibEntry newEntry, BibDatabaseContext databaseContext, DialogService dialogService, - StateManager stateManager, ThemeManager themeManager, PreferencesService preferencesService, BibEntryTypesManager entryTypesManager, @@ -44,7 +40,7 @@ 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, stateManager, themeManager, taskExecutor); + PreviewViewer previewClone = new PreviewViewer(databaseContext, dialogService, preferencesService, themeManager, taskExecutor); // The scroll bar used is not part of ScrollPane, but the attached WebView. WebView previewCloneView = (WebView) previewClone.getContent(); @@ -53,7 +49,9 @@ public EntryChangeDetailsView(BibEntry oldEntry, synchronizeScrolling(previewViewerView, previewCloneView); // TODO: Also sync scrolling for BibTeX view. + PreviewWithSourceTab oldPreviewWithSourcesTab = new PreviewWithSourceTab(); TabPane oldEntryTabPane = oldPreviewWithSourcesTab.getPreviewWithSourceTab(oldEntry, databaseContext, preferencesService, entryTypesManager, previewClone, Localization.lang("Entry Preview")); + PreviewWithSourceTab newPreviewWithSourcesTab = new PreviewWithSourceTab(); TabPane newEntryTabPane = newPreviewWithSourcesTab.getPreviewWithSourceTab(newEntry, databaseContext, preferencesService, entryTypesManager, previewViewer, Localization.lang("Entry Preview")); EasyBind.subscribe(oldEntryTabPane.getSelectionModel().selectedIndexProperty(), selectedIndex -> { diff --git a/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java b/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java index 0bfc0ffa1dc..cef2ba9e160 100644 --- a/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/CommentsTab.java @@ -17,7 +17,6 @@ import javafx.scene.layout.RowConstraints; import org.jabref.gui.DialogService; -import org.jabref.gui.StateManager; import org.jabref.gui.autocompleter.SuggestionProviders; import org.jabref.gui.fieldeditors.FieldEditorFX; import org.jabref.gui.fieldeditors.FieldNameLabel; @@ -25,10 +24,12 @@ 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.l10n.Localization; import org.jabref.logic.pdf.search.IndexingTaskManager; +import org.jabref.logic.search.SearchQuery; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; @@ -51,11 +52,11 @@ public CommentsTab(PreferencesService preferences, UndoAction undoAction, RedoAction redoAction, DialogService dialogService, - StateManager stateManager, ThemeManager themeManager, IndexingTaskManager indexingTaskManager, TaskExecutor taskExecutor, - JournalAbbreviationRepository journalAbbreviationRepository) { + JournalAbbreviationRepository journalAbbreviationRepository, + OptionalObjectProperty searchQueryProperty) { super( false, databaseContext, @@ -65,11 +66,11 @@ public CommentsTab(PreferencesService preferences, redoAction, dialogService, preferences, - stateManager, themeManager, taskExecutor, journalAbbreviationRepository, - indexingTaskManager + indexingTaskManager, + searchQueryProperty ); this.defaultOwner = preferences.getOwnerPreferences().getDefaultOwner().toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9]", "-"); setText(Localization.lang("Comments")); diff --git a/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java b/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java index 78eab1dd9ed..00da70da64d 100644 --- a/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java @@ -10,16 +10,17 @@ import javafx.scene.control.Tooltip; import org.jabref.gui.DialogService; -import org.jabref.gui.StateManager; import org.jabref.gui.autocompleter.SuggestionProviders; import org.jabref.gui.icon.IconTheme; 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.l10n.Localization; import org.jabref.logic.pdf.search.IndexingTaskManager; +import org.jabref.logic.search.SearchQuery; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; @@ -42,13 +43,13 @@ public DeprecatedFieldsTab(BibDatabaseContext databaseContext, RedoAction redoAction, DialogService dialogService, PreferencesService preferences, - StateManager stateManager, ThemeManager themeManager, IndexingTaskManager indexingTaskManager, BibEntryTypesManager entryTypesManager, TaskExecutor taskExecutor, - JournalAbbreviationRepository journalAbbreviationRepository) { - super(false, databaseContext, suggestionProviders, undoManager, undoAction, redoAction, dialogService, preferences, stateManager, themeManager, taskExecutor, journalAbbreviationRepository, indexingTaskManager); + JournalAbbreviationRepository journalAbbreviationRepository, + OptionalObjectProperty searchQueryProperty) { + super(false, databaseContext, suggestionProviders, undoManager, undoAction, redoAction, dialogService, preferences, themeManager, taskExecutor, journalAbbreviationRepository, indexingTaskManager, searchQueryProperty); 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 8fe322331b8..ecd387e5546 100644 --- a/src/main/java/org/jabref/gui/entryeditor/DetailOptionalFieldsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/DetailOptionalFieldsTab.java @@ -3,15 +3,16 @@ import javax.swing.undo.UndoManager; import org.jabref.gui.DialogService; -import org.jabref.gui.StateManager; import org.jabref.gui.autocompleter.SuggestionProviders; 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.l10n.Localization; import org.jabref.logic.pdf.search.IndexingTaskManager; +import org.jabref.logic.search.SearchQuery; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.preferences.PreferencesService; @@ -27,12 +28,12 @@ public DetailOptionalFieldsTab(BibDatabaseContext databaseContext, RedoAction redoAction, DialogService dialogService, PreferencesService preferences, - StateManager stateManager, ThemeManager themeManager, IndexingTaskManager indexingTaskManager, BibEntryTypesManager entryTypesManager, TaskExecutor taskExecutor, - JournalAbbreviationRepository journalAbbreviationRepository) { + JournalAbbreviationRepository journalAbbreviationRepository, + OptionalObjectProperty searchQueryProperty) { super( Localization.lang("Optional fields 2"), false, @@ -43,12 +44,12 @@ public DetailOptionalFieldsTab(BibDatabaseContext databaseContext, redoAction, dialogService, preferences, - stateManager, themeManager, indexingTaskManager, entryTypesManager, taskExecutor, - journalAbbreviationRepository + journalAbbreviationRepository, + searchQueryProperty ); } } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index f0a460ba93d..3a752018c96 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -278,21 +278,21 @@ private void navigateToNextEntry() { private List createTabs() { List tabs = new LinkedList<>(); - tabs.add(new PreviewTab(databaseContext, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor)); + tabs.add(new PreviewTab(databaseContext, dialogService, preferencesService, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, libraryTab.searchQueryProperty())); // Required, optional (important+detail), deprecated, and "other" fields - tabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - tabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - tabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - tabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - tabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); + tabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty())); + tabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty())); + tabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty())); + tabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty())); + tabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty())); // Comment Tab: Tab for general and user-specific comments - tabs.add(new CommentsTab(preferencesService, databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository)); + tabs.add(new CommentsTab(preferencesService, databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty())); 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, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository)); + tabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferencesService, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty())); } 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 2fa51d23a19..b0ea9c742f0 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java @@ -25,7 +25,6 @@ import javafx.scene.layout.RowConstraints; import org.jabref.gui.DialogService; -import org.jabref.gui.StateManager; import org.jabref.gui.autocompleter.SuggestionProviders; import org.jabref.gui.fieldeditors.FieldEditorFX; import org.jabref.gui.fieldeditors.FieldEditors; @@ -34,9 +33,11 @@ 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.pdf.search.IndexingTaskManager; +import org.jabref.logic.search.SearchQuery; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; @@ -61,11 +62,12 @@ abstract class FieldsEditorTab extends EntryEditorTab implements OffersPreview { private final ThemeManager themeManager; private final TaskExecutor taskExecutor; private final JournalAbbreviationRepository journalAbbreviationRepository; - private final StateManager stateManager; private final IndexingTaskManager indexingTaskManager; private PreviewPanel previewPanel; private final UndoManager undoManager; + private final OptionalObjectProperty searchQueryProperty; private Collection fields = new ArrayList<>(); + @SuppressWarnings("FieldCanBeLocal") private Subscription dividerPositionSubscription; public FieldsEditorTab(boolean compressed, @@ -76,11 +78,11 @@ public FieldsEditorTab(boolean compressed, RedoAction redoAction, DialogService dialogService, PreferencesService preferences, - StateManager stateManager, ThemeManager themeManager, TaskExecutor taskExecutor, JournalAbbreviationRepository journalAbbreviationRepository, - IndexingTaskManager indexingTaskManager) { + IndexingTaskManager indexingTaskManager, + OptionalObjectProperty searchQueryProperty) { this.isCompressed = compressed; this.databaseContext = Objects.requireNonNull(databaseContext); this.suggestionProviders = Objects.requireNonNull(suggestionProviders); @@ -92,8 +94,8 @@ public FieldsEditorTab(boolean compressed, this.themeManager = themeManager; this.taskExecutor = Objects.requireNonNull(taskExecutor); this.journalAbbreviationRepository = Objects.requireNonNull(journalAbbreviationRepository); - this.stateManager = stateManager; this.indexingTaskManager = indexingTaskManager; + this.searchQueryProperty = searchQueryProperty; } private static void addColumn(GridPane gridPane, int columnIndex, List