Skip to content

Commit

Permalink
Update PreviewView to listen for library search queries (#11659)
Browse files Browse the repository at this point in the history
* Update PreviewView to listen for library search queries

* unnecessary updates in PreviewViewer when hovering over entries

* Update CHANGELOG.md

* Update CommentsTabTest.java

* Invert "if" condition
  • Loading branch information
LoayGhreeb authored Aug 21, 2024
1 parent 75ace11 commit 8c51e7a
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 131 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue with query transformers (JStor and others). [#11643](https://github.com/JabRef/jabref/pull/11643)
- We fixed an issue where a new unsaved library was not marked with an asterisk. [#11519](https://github.com/JabRef/jabref/pull/11519)
- We fixed an issue where JabRef starts without window decorations. [#11440](https://github.com/JabRef/jabref/pull/11440)
- We fixed an issue where the entry preview highlight was not working when searching before opening the entry editor. [#11659](https://github.com/JabRef/jabref/pull/11659)

### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -40,15 +38,13 @@ public class DatabaseChangeDetailsViewFactory {

public DatabaseChangeDetailsViewFactory(BibDatabaseContext databaseContext,
DialogService dialogService,
StateManager stateManager,
ThemeManager themeManager,
PreferencesService preferencesService,
BibEntryTypesManager entryTypesManager,
PreviewViewer previewViewer,
TaskExecutor taskExecutor) {
this.databaseContext = databaseContext;
this.dialogService = dialogService;
this.stateManager = stateManager;
this.themeManager = themeManager;
this.preferencesService = preferencesService;
this.entryTypesManager = entryTypesManager;
Expand All @@ -63,7 +59,6 @@ public DatabaseChangeDetailsView create(DatabaseChange databaseChange) {
entryChange.getNewEntry(),
databaseContext,
dialogService,
stateManager,
themeManager,
preferencesService,
entryTypesManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,7 +56,6 @@ public class DatabaseChangesResolverDialog extends BaseDialog<Boolean> {
private boolean areAllChangesDenied;

@Inject private UndoManager undoManager;
@Inject private StateManager stateManager;
@Inject private DialogService dialogService;
@Inject private PreferencesService preferencesService;
@Inject private ThemeManager themeManager;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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();
Expand All @@ -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 -> {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/jabref/gui/entryeditor/CommentsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
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;
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.entry.BibEntry;
import org.jabref.model.entry.field.Field;
Expand All @@ -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<SearchQuery> searchQueryProperty) {
super(
false,
databaseContext,
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SearchQuery> searchQueryProperty) {
super(false, databaseContext, suggestionProviders, undoManager, undoAction, redoAction, dialogService, preferences, themeManager, taskExecutor, journalAbbreviationRepository, indexingTaskManager, searchQueryProperty);
this.entryTypesManager = entryTypesManager;

setText(Localization.lang("Deprecated fields"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SearchQuery> searchQueryProperty) {
super(
Localization.lang("Optional fields 2"),
false,
Expand All @@ -43,12 +44,12 @@ public DetailOptionalFieldsTab(BibDatabaseContext databaseContext,
redoAction,
dialogService,
preferences,
stateManager,
themeManager,
indexingTaskManager,
entryTypesManager,
taskExecutor,
journalAbbreviationRepository
journalAbbreviationRepository,
searchQueryProperty
);
}
}
16 changes: 8 additions & 8 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,21 @@ private void navigateToNextEntry() {
private List<EntryEditorTab> createTabs() {
List<EntryEditorTab> 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<String, Set<Field>> entryEditorTabList = getAdditionalUserConfiguredTabs();
for (Map.Entry<String, Set<Field>> 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());
Expand Down
Loading

0 comments on commit 8c51e7a

Please sign in to comment.