diff --git a/build.gradle b/build.gradle index f3fdf3233d0..8a7257a3d33 100644 --- a/build.gradle +++ b/build.gradle @@ -182,7 +182,7 @@ dependencies { antlr4 'org.antlr:antlr4:4.13.1' implementation 'org.antlr:antlr4-runtime:4.13.1' - implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '6.9.0.202403050737-r' + implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '6.10.0.202406032230-r' implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.1' implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.17.1' @@ -218,7 +218,7 @@ dependencies { } implementation 'org.fxmisc.flowless:flowless:0.7.3' implementation 'org.fxmisc.richtext:richtextfx:0.11.2' - implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.23.0') { + implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.25.0') { exclude module: 'javax.inject' // Split package, use only jakarta.inject exclude module: 'commons-lang3' exclude group: 'org.openjfx' diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index e35431134e6..7fa79f9166b 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -565,7 +565,7 @@ private void createMainTable() { stateManager.setSelectedEntries(entries); if (!entries.isEmpty()) { // Update entry editor and preview according to selected entries - entryEditor.setEntry(entries.getFirst()); + entryEditor.setCurrentlyEditedEntry(entries.getFirst()); } }); } @@ -639,7 +639,7 @@ public void showAndEdit(BibEntry entry) { // We use != instead of equals because of performance reasons if (entry != showing) { - entryEditor.setEntry(entry); + entryEditor.setCurrentlyEditedEntry(entry); showing = entry; } entryEditor.requestFocus(); @@ -682,14 +682,14 @@ public void entryEditorClosing() { private void ensureNotShowingBottomPanel(List entriesToCheck) { // This method is not able to close the bottom pane currently - if ((mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) && (entriesToCheck.contains(entryEditor.getEntry()))) { + if ((mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) && (entriesToCheck.contains(entryEditor.getCurrentlyEditedEntry()))) { closeBottomPane(); } } public void updateEntryEditorIfShowing() { if (mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) { - BibEntry currentEntry = entryEditor.getEntry(); + BibEntry currentEntry = entryEditor.getCurrentlyEditedEntry(); showAndEdit(currentEntry); } } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index f8ee4bc186f..97cbf39e6ff 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -2,6 +2,7 @@ import java.io.File; import java.nio.file.Path; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -90,26 +91,16 @@ public class EntryEditor extends BorderPane { private Subscription typeSubscription; - /* - * Reference to the entry this editor works on. - */ - private BibEntry entry; + private BibEntry currentlyEditedEntry; private SourceTab sourceTab; - /* - * tabs to be shown in GUI - */ @FXML private TabPane tabbed; - /* - * Tabs which can apply filter, but seems non-sense - */ - private final List tabs; - @FXML private Button typeChangeButton; @FXML private Button fetcherButton; @FXML private Label typeLabel; + @Inject private BuildInfo buildInfo; @Inject private DialogService dialogService; @Inject private TaskExecutor taskExecutor; @@ -122,7 +113,8 @@ public class EntryEditor extends BorderPane { @Inject private KeyBindingRepository keyBindingRepository; @Inject private JournalAbbreviationRepository journalAbbreviationRepository; - private final List entryEditorTabs = new LinkedList<>(); + private final List allPossibleTabs; + private final Collection previewTabs; public EntryEditor(LibraryTab libraryTab) { this.libraryTab = libraryTab; @@ -136,28 +128,33 @@ public EntryEditor(LibraryTab libraryTab) { this.entryEditorPreferences = preferencesService.getEntryEditorPreferences(); this.fileLinker = new ExternalFilesEntryLinker(preferencesService.getFilePreferences(), databaseContext, dialogService); + setupKeyBindings(); + + this.allPossibleTabs = createTabs(); + this.previewTabs = this.allPossibleTabs.stream().filter(OffersPreview.class::isInstance).map(OffersPreview.class::cast).toList(); + + setupDragAndDrop(libraryTab); + EasyBind.subscribe(tabbed.getSelectionModel().selectedItemProperty(), tab -> { EntryEditorTab activeTab = (EntryEditorTab) tab; if (activeTab != null) { - activeTab.notifyAboutFocus(entry); + activeTab.notifyAboutFocus(currentlyEditedEntry); } }); + EasyBind.listen(preferencesService.getPreviewPreferences().showPreviewAsExtraTabProperty(), + (obs, oldValue, newValue) -> adaptVisibleTabs()); + } - setupKeyBindings(); - - this.tabs = createTabs(); - + private void setupDragAndDrop(LibraryTab libraryTab) { this.setOnDragOver(event -> { if (event.getDragboard().hasFiles()) { event.acceptTransferModes(TransferMode.COPY, TransferMode.MOVE, TransferMode.LINK); } event.consume(); }); - this.setOnDragDropped(event -> { - BibEntry entry = this.getEntry(); + BibEntry entry = this.getCurrentlyEditedEntry(); boolean success = false; - if (event.getDragboard().hasContent(DataFormat.FILES)) { List draggedFiles = event.getDragboard().getFiles().stream().map(File::toPath).collect(Collectors.toList()); switch (event.getTransferMode()) { @@ -183,7 +180,7 @@ public EntryEditor(LibraryTab libraryTab) { } /** - * Set-up key bindings specific for the entry editor. + * Set up key bindings specific for the entry editor. */ private void setupKeyBindings() { this.addEventHandler(KeyEvent.KEY_PRESSED, event -> { @@ -235,19 +232,19 @@ public void close() { @FXML private void deleteEntry() { - libraryTab.delete(entry); + libraryTab.delete(currentlyEditedEntry); } @FXML void generateCiteKeyButton() { - GenerateCitationKeySingleAction action = new GenerateCitationKeySingleAction(getEntry(), databaseContext, + GenerateCitationKeySingleAction action = new GenerateCitationKeySingleAction(getCurrentlyEditedEntry(), databaseContext, dialogService, preferencesService, undoManager); action.execute(); } @FXML void generateCleanupButton() { - CleanupSingleAction action = new CleanupSingleAction(getEntry(), preferencesService, dialogService, stateManager, undoManager); + CleanupSingleAction action = new CleanupSingleAction(getCurrentlyEditedEntry(), preferencesService, dialogService, stateManager, undoManager); action.execute(); } @@ -262,54 +259,31 @@ private void navigateToNextEntry() { } private List createTabs() { - entryEditorTabs.add(new PreviewTab(databaseContext, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor)); + List tabs = new LinkedList<>(); + + tabs.add(new PreviewTab(databaseContext, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor)); // Required, optional (important+detail), deprecated, and "other" fields - entryEditorTabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - entryEditorTabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - entryEditorTabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - entryEditorTabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); - entryEditorTabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); + tabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); + tabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); + tabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); + tabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); + tabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, taskExecutor, journalAbbreviationRepository)); // Comment Tab: Tab for general and user-specific comments - entryEditorTabs.add(new CommentsTab(preferencesService, databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository)); - - // The preferences allow to configure tabs to show (e.g.,"General", "Abstract") - // These should be shown. Already hard-coded ones should be removed. - Map> entryEditorTabList = new HashMap<>(entryEditorPreferences.getEntryEditorTabs()); - entryEditorTabList.remove(PreviewTab.NAME); - entryEditorTabList.remove(RequiredFieldsTab.NAME); - entryEditorTabList.remove(ImportantOptionalFieldsTab.NAME); - entryEditorTabList.remove(DetailOptionalFieldsTab.NAME); - entryEditorTabList.remove(DeprecatedFieldsTab.NAME); - entryEditorTabList.remove(OtherFieldsTab.NAME); - entryEditorTabList.remove(CommentsTab.NAME); - entryEditorTabList.remove(MathSciNetTab.NAME); - entryEditorTabList.remove(FileAnnotationTab.NAME); - entryEditorTabList.remove(SciteTab.NAME); - // CitationRelationsTab - entryEditorTabList.remove(RelatedArticlesTab.NAME); - // SourceTab -- not listed, because it has different names for BibTeX and biblatex mode - entryEditorTabList.remove(LatexCitationsTab.NAME); - entryEditorTabList.remove(FulltextSearchResultsTab.NAME); + tabs.add(new CommentsTab(preferencesService, databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository)); + Map> entryEditorTabList = getAdditionalUserConfiguredTabs(); for (Map.Entry> tab : entryEditorTabList.entrySet()) { - entryEditorTabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository)); + tabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), taskExecutor, journalAbbreviationRepository)); } - entryEditorTabs.add(new MathSciNetTab()); - entryEditorTabs.add(new FileAnnotationTab(libraryTab.getAnnotationCache())); - entryEditorTabs.add(new SciteTab(preferencesService, taskExecutor, dialogService)); - entryEditorTabs.add(new CitationRelationsTab( - dialogService, - databaseContext, - undoManager, - stateManager, - fileMonitor, - preferencesService, - libraryTab, - taskExecutor)); - entryEditorTabs.add(new RelatedArticlesTab(buildInfo, entryEditorPreferences, preferencesService, dialogService, taskExecutor)); + tabs.add(new MathSciNetTab()); + tabs.add(new FileAnnotationTab(libraryTab.getAnnotationCache())); + tabs.add(new SciteTab(preferencesService, taskExecutor, dialogService)); + tabs.add(new CitationRelationsTab(dialogService, databaseContext, + undoManager, stateManager, fileMonitor, preferencesService, libraryTab, taskExecutor)); + tabs.add(new RelatedArticlesTab(buildInfo, preferencesService, dialogService, taskExecutor)); sourceTab = new SourceTab( databaseContext, undoManager, @@ -320,27 +294,60 @@ private List createTabs() { stateManager, bibEntryTypesManager, keyBindingRepository); - entryEditorTabs.add(sourceTab); - entryEditorTabs.add(new LatexCitationsTab(databaseContext, preferencesService, dialogService, directoryMonitorManager)); - entryEditorTabs.add(new FulltextSearchResultsTab(stateManager, preferencesService, dialogService, taskExecutor)); + tabs.add(sourceTab); + tabs.add(new LatexCitationsTab(databaseContext, preferencesService, dialogService, directoryMonitorManager)); + tabs.add(new FulltextSearchResultsTab(stateManager, preferencesService, dialogService, taskExecutor)); - return entryEditorTabs; + return tabs; } - private void recalculateVisibleTabs() { - List visibleTabs = tabs.stream().filter(tab -> tab.shouldShow(entry)).collect(Collectors.toList()); + /** + * The preferences allow to configure tabs to show (e.g.,"General", "Abstract") + * These should be shown. Already hard-coded ones (above and below this code block) should be removed. + * This method does this calculation. + * + * @return Map of tab names and the fields to show in them. + */ + private Map> getAdditionalUserConfiguredTabs() { + Map> entryEditorTabList = new HashMap<>(entryEditorPreferences.getEntryEditorTabs()); + + // Same order as in org.jabref.gui.entryeditor.EntryEditor.createTabs before the call of getAdditionalUserConfiguredTabs + entryEditorTabList.remove(PreviewTab.NAME); + entryEditorTabList.remove(RequiredFieldsTab.NAME); + entryEditorTabList.remove(ImportantOptionalFieldsTab.NAME); + entryEditorTabList.remove(DetailOptionalFieldsTab.NAME); + entryEditorTabList.remove(DeprecatedFieldsTab.NAME); + entryEditorTabList.remove(OtherFieldsTab.NAME); + entryEditorTabList.remove(CommentsTab.NAME); + + // Same order as in org.jabref.gui.entryeditor.EntryEditor.createTabs after the call of getAdditionalUserConfiguredTabs + entryEditorTabList.remove(MathSciNetTab.NAME); + entryEditorTabList.remove(FileAnnotationTab.NAME); + entryEditorTabList.remove(SciteTab.NAME); + entryEditorTabList.remove(CitationRelationsTab.NAME); + entryEditorTabList.remove(RelatedArticlesTab.NAME); + // SourceTab is not listed, because it has different names for BibTeX and biblatex mode + entryEditorTabList.remove(LatexCitationsTab.NAME); + entryEditorTabList.remove(FulltextSearchResultsTab.NAME); + + return entryEditorTabList; + } - // Start of ugly hack: - // We need to find out, which tabs will be shown and which not and remove and re-add the appropriate tabs - // to the editor. We don't want to simply remove all and re-add the complete list of visible tabs, because - // the tabs give an ugly animation the looks like all tabs are shifting in from the right. + /** + * Adapt the visible tabs to the current entry type. + */ + private void adaptVisibleTabs() { + // We need to find out, which tabs will be shown (and which not anymore) and remove and re-add the appropriate tabs + // to the editor. We cannot to simply remove all and re-add the complete list of visible tabs, because + // the tabs give an ugly animation the looks like all tabs are shifting in from the right. In other words: // This hack is required since tabbed.getTabs().setAll(visibleTabs) changes the order of the tabs in the editor // First, remove tabs that we do not want to show - List toBeRemoved = tabs.stream().filter(tab -> !tab.shouldShow(entry)).toList(); + List toBeRemoved = allPossibleTabs.stream().filter(tab -> !tab.shouldShow(currentlyEditedEntry)).toList(); tabbed.getTabs().removeAll(toBeRemoved); // Next add all the visible tabs (if not already present) at the right position + List visibleTabs = allPossibleTabs.stream().filter(tab -> tab.shouldShow(currentlyEditedEntry)).collect(Collectors.toList()); for (int i = 0; i < visibleTabs.size(); i++) { Tab toBeAdded = visibleTabs.get(i); Tab shown = null; @@ -358,42 +365,31 @@ private void recalculateVisibleTabs() { /** * @return the currently edited entry */ - public BibEntry getEntry() { - return entry; + public BibEntry getCurrentlyEditedEntry() { + return currentlyEditedEntry; } - /** - * Sets the entry to edit. - */ - public void setEntry(BibEntry entry) { - Objects.requireNonNull(entry); + public void setCurrentlyEditedEntry(BibEntry currentlyEditedEntry) { + this.currentlyEditedEntry = Objects.requireNonNull(currentlyEditedEntry); - // Remove subscription for old entry if existing + // Subscribe to type changes for rebuilding the currently visible tab if (typeSubscription != null) { + // Remove subscription for old entry if existing typeSubscription.unsubscribe(); } + typeSubscription = EasyBind.subscribe(this.currentlyEditedEntry.typeProperty(), type -> { + typeLabel.setText(new TypedBibEntry(currentlyEditedEntry, databaseContext.getMode()).getTypeForDisplay()); + adaptVisibleTabs(); + getSelectedTab().notifyAboutFocus(currentlyEditedEntry); + }); - this.entry = entry; - - recalculateVisibleTabs(); - EasyBind.listen(preferencesService.getPreviewPreferences().showPreviewAsExtraTabProperty(), - (obs, oldValue, newValue) -> recalculateVisibleTabs()); + adaptVisibleTabs(); + setupToolBar(); if (entryEditorPreferences.showSourceTabByDefault()) { tabbed.getSelectionModel().select(sourceTab); } - - // Notify current tab about new entry - getSelectedTab().notifyAboutFocus(entry); - - setupToolBar(); - - // Subscribe to type changes for rebuilding the currently visible tab - typeSubscription = EasyBind.subscribe(this.entry.typeProperty(), type -> { - typeLabel.setText(new TypedBibEntry(entry, databaseContext.getMode()).getTypeForDisplay()); - recalculateVisibleTabs(); - getSelectedTab().notifyAboutFocus(entry); - }); + getSelectedTab().notifyAboutFocus(currentlyEditedEntry); } private EntryEditorTab getSelectedTab() { @@ -402,11 +398,11 @@ private EntryEditorTab getSelectedTab() { private void setupToolBar() { // Update type label - TypedBibEntry typedEntry = new TypedBibEntry(entry, databaseContext.getMode()); + TypedBibEntry typedEntry = new TypedBibEntry(currentlyEditedEntry, databaseContext.getMode()); typeLabel.setText(typedEntry.getTypeForDisplay()); // Add type change menu - ContextMenu typeMenu = new ChangeEntryTypeMenu(Collections.singletonList(entry), databaseContext, undoManager, bibEntryTypesManager).asContextMenu(); + ContextMenu typeMenu = new ChangeEntryTypeMenu(Collections.singletonList(currentlyEditedEntry), databaseContext, undoManager, bibEntryTypesManager).asContextMenu(); typeLabel.setOnMouseClicked(event -> typeMenu.show(typeLabel, Side.RIGHT, 0, 0)); typeChangeButton.setOnMouseClicked(event -> typeMenu.show(typeChangeButton, Side.RIGHT, 0, 0)); @@ -440,7 +436,7 @@ private void setupToolBar() { } private void fetchAndMerge(EntryBasedFetcher fetcher) { - new FetchAndMergeEntry(libraryTab.getBibDatabaseContext(), taskExecutor, preferencesService, dialogService, undoManager).fetchAndMerge(entry, fetcher); + new FetchAndMergeEntry(libraryTab.getBibDatabaseContext(), taskExecutor, preferencesService, dialogService, undoManager).fetchAndMerge(currentlyEditedEntry, fetcher); } public void setFocusToField(Field field) { @@ -456,10 +452,10 @@ public void setFocusToField(Field field) { } public void nextPreviewStyle() { - this.entryEditorTabs.forEach(EntryEditorTab::nextPreviewStyle); + this.previewTabs.forEach(OffersPreview::nextPreviewStyle); } public void previousPreviewStyle() { - this.entryEditorTabs.forEach(EntryEditorTab::previousPreviewStyle); + this.previewTabs.forEach(OffersPreview::previousPreviewStyle); } } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java index 6433f21c6b9..1ac5ec4149b 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java @@ -43,18 +43,4 @@ public void notifyAboutFocus(BibEntry entry) { } handleFocus(); } - - /** - * Switch to next Preview style - should be overriden if a EntryEditorTab is actually showing a preview - */ - protected void nextPreviewStyle() { - // do nothing by default - } - - /** - * Switch to previous Preview style - should be overriden if a EntryEditorTab is actually showing a preview - */ - protected void previousPreviewStyle() { - // do nothing by default - } } diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java index 97348f5838a..f251d24c1d0 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java @@ -46,7 +46,7 @@ /** * A single tab displayed in the EntryEditor holding several FieldEditors. */ -abstract class FieldsEditorTab extends EntryEditorTab { +abstract class FieldsEditorTab extends EntryEditorTab implements OffersPreview { protected final BibDatabaseContext databaseContext; protected final Map editors = new LinkedHashMap<>(); protected GridPane gridPane; @@ -213,14 +213,14 @@ protected void bindToEntry(BibEntry entry) { } @Override - protected void nextPreviewStyle() { + public void nextPreviewStyle() { if (previewPanel != null) { previewPanel.nextPreviewStyle(); } } @Override - protected void previousPreviewStyle() { + public void previousPreviewStyle() { if (previewPanel != null) { previewPanel.previousPreviewStyle(); } diff --git a/src/main/java/org/jabref/gui/entryeditor/OffersPreview.java b/src/main/java/org/jabref/gui/entryeditor/OffersPreview.java new file mode 100644 index 00000000000..7aa79663c9f --- /dev/null +++ b/src/main/java/org/jabref/gui/entryeditor/OffersPreview.java @@ -0,0 +1,14 @@ +package org.jabref.gui.entryeditor; + +public interface OffersPreview { + + /** + * Switch to next Preview style - should be overriden if a EntryEditorTab is actually showing a preview + */ + void nextPreviewStyle(); + + /** + * Switch to previous Preview style - should be overriden if a EntryEditorTab is actually showing a preview + */ + void previousPreviewStyle(); +} diff --git a/src/main/java/org/jabref/gui/entryeditor/PreviewTab.java b/src/main/java/org/jabref/gui/entryeditor/PreviewTab.java index 648cbe003a8..bd0fef9c980 100644 --- a/src/main/java/org/jabref/gui/entryeditor/PreviewTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/PreviewTab.java @@ -12,7 +12,7 @@ import org.jabref.model.entry.BibEntry; import org.jabref.preferences.PreferencesService; -public class PreviewTab extends EntryEditorTab { +public class PreviewTab extends EntryEditorTab implements OffersPreview { public static final String NAME = "Preview"; private final DialogService dialogService; private final BibDatabaseContext databaseContext; @@ -43,14 +43,14 @@ public PreviewTab(BibDatabaseContext databaseContext, } @Override - protected void nextPreviewStyle() { + public void nextPreviewStyle() { if (previewPanel != null) { previewPanel.nextPreviewStyle(); } } @Override - protected void previousPreviewStyle() { + public void previousPreviewStyle() { if (previewPanel != null) { previewPanel.previousPreviewStyle(); } diff --git a/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java b/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java index 3dc16596746..fe70d07c31e 100644 --- a/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java @@ -37,30 +37,31 @@ import org.slf4j.LoggerFactory; /** - * GUI for tab displaying article recommendations based on the currently selected BibEntry + * Tab displaying article recommendations based on the currently selected BibEntry */ public class RelatedArticlesTab extends EntryEditorTab { public static final String NAME = "Related articles"; private static final Logger LOGGER = LoggerFactory.getLogger(RelatedArticlesTab.class); - private final EntryEditorPreferences preferences; + private final DialogService dialogService; - private final PreferencesService preferencesService; private final BuildInfo buildInfo; private final TaskExecutor taskExecutor; + private final PreferencesService preferencesService; + public RelatedArticlesTab(BuildInfo buildInfo, - EntryEditorPreferences preferences, PreferencesService preferencesService, DialogService dialogService, TaskExecutor taskExecutor) { + this.dialogService = dialogService; this.buildInfo = buildInfo; this.taskExecutor = taskExecutor; + + this.preferencesService = preferencesService; + setText(Localization.lang("Related articles")); setTooltip(new Tooltip(Localization.lang("Related articles"))); - this.preferences = preferences; - this.dialogService = dialogService; - this.preferencesService = preferencesService; } /** @@ -241,15 +242,16 @@ private ScrollPane getPrivacyDialog(BibEntry entry) { @Override public boolean shouldShow(BibEntry entry) { - return preferences.shouldShowRecommendationsTab(); + EntryEditorPreferences entryEditorPreferences = preferencesService.getEntryEditorPreferences(); + return entryEditorPreferences.shouldShowRecommendationsTab(); } @Override protected void bindToEntry(BibEntry entry) { - // Ask for consent to send data to Mr. DLib on first time to tab if (preferencesService.getMrDlibPreferences().shouldAcceptRecommendations()) { setContent(getRelatedArticlesPane(entry)); } else { + // Ask for consent to send data to Mr. DLib on first time to tab setContent(getPrivacyDialog(entry)); } } 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 dc6ea47a1af..e774d0a1b4f 100644 --- a/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/CitationRelationsTab.java @@ -59,6 +59,8 @@ */ public class CitationRelationsTab extends EntryEditorTab { + public static final String NAME = "Citation relations"; + private static final Logger LOGGER = LoggerFactory.getLogger(CitationRelationsTab.class); // Tasks used to implement asynchronous fetching of related articles @@ -79,12 +81,12 @@ public CitationRelationsTab(DialogService dialogService, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor, PreferencesService preferencesService, - LibraryTab lTab, + LibraryTab libraryTab, TaskExecutor taskExecutor) { this.dialogService = dialogService; this.databaseContext = databaseContext; this.preferencesService = preferencesService; - this.libraryTab = lTab; + this.libraryTab = libraryTab; this.taskExecutor = taskExecutor; setText(Localization.lang("Citation relations")); setTooltip(new Tooltip(Localization.lang("Show articles related by citation"))); diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java index 26efd550e19..8af19bbcfd1 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java @@ -142,7 +142,7 @@ public void listen(SharedEntriesNotPresentEvent event) { libraryTab.getUndoManager().addEdit(new UndoableRemoveEntries(libraryTab.getDatabase(), event.getBibEntries())); - if (entryEditor != null && (event.getBibEntries().contains(entryEditor.getEntry()))) { + if (entryEditor != null && (event.getBibEntries().contains(entryEditor.getCurrentlyEditedEntry()))) { dialogService.showInformationDialogAndWait(Localization.lang("Shared entry is no longer present"), Localization.lang("The entry you currently work on has been deleted on the shared side.") + "\n" diff --git a/src/main/resources/csl-styles b/src/main/resources/csl-styles index 48ca7a2086d..b2be5aeeee7 160000 --- a/src/main/resources/csl-styles +++ b/src/main/resources/csl-styles @@ -1 +1 @@ -Subproject commit 48ca7a2086d0969802eaa70d9b2d2b4ed849b1cf +Subproject commit b2be5aeeee7f00fd2032ac1daad995bbe95398cf