From 150603c95927c2ef78e9d1c6ac82b39df2bcf8af Mon Sep 17 00:00:00 2001 From: subhramit Date: Tue, 17 Sep 2024 03:29:47 +0530 Subject: [PATCH 1/9] Clean up dead code --- .../gui/openoffice/OpenOfficePanel.java | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index f4337d33545..1413db39d05 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -128,8 +128,8 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, this.stateManager = stateManager; this.clipBoardManager = clipBoardManager; this.undoManager = undoManager; - this.currentStyle = preferences.getOpenOfficePreferences().getCurrentStyle(); this.openOfficePreferences = preferences.getOpenOfficePreferences(); + this.currentStyle = openOfficePreferences.getCurrentStyle(); ActionFactory factory = new ActionFactory(); @@ -157,7 +157,7 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, update.setMaxWidth(Double.MAX_VALUE); loader = new StyleLoader( - preferences.getOpenOfficePreferences(), + openOfficePreferences, preferences.getLayoutFormatterPreferences(), abbreviationRepository); @@ -327,7 +327,7 @@ private void exportEntries() { private List getBaseList() { List databases = new ArrayList<>(); - if (preferences.getOpenOfficePreferences().getUseAllDatabases()) { + if (openOfficePreferences.getUseAllDatabases()) { for (BibDatabaseContext database : stateManager.getOpenDatabases()) { databases.add(database.getDatabase()); } @@ -341,7 +341,7 @@ private List getBaseList() { } private void connectAutomatically() { - DetectOpenOfficeInstallation officeInstallation = new DetectOpenOfficeInstallation(preferences.getOpenOfficePreferences(), dialogService); + DetectOpenOfficeInstallation officeInstallation = new DetectOpenOfficeInstallation(openOfficePreferences, dialogService); if (officeInstallation.isExecutablePathDefined()) { connect(); @@ -375,7 +375,7 @@ private void connectManually() { var fileDialogConfiguration = new DirectoryDialogConfiguration.Builder().withInitialDirectory(System.getProperty("user.home")).build(); Optional selectedPath = dialogService.showDirectorySelectionDialog(fileDialogConfiguration); - DetectOpenOfficeInstallation officeInstallation = new DetectOpenOfficeInstallation(preferences.getOpenOfficePreferences(), dialogService); + DetectOpenOfficeInstallation officeInstallation = new DetectOpenOfficeInstallation(openOfficePreferences, dialogService); if (selectedPath.isPresent()) { BackgroundTask.wrap(() -> officeInstallation.setOpenOfficePreferences(selectedPath.get())) @@ -397,28 +397,20 @@ private void updateButtonAvailability() { boolean isConnected = ooBase != null; boolean isConnectedToDocument = isConnected && !ooBase.isDocumentConnectionMissing(); - // For these, we need to watch something - boolean hasStyle = true; // (style != null); - boolean hasDatabase = true; // !getBaseList().isEmpty(); - boolean hasSelectedBibEntry = true; - selectDocument.setDisable(!isConnected); - pushEntries.setDisable(!(isConnectedToDocument && hasStyle && hasDatabase)); + pushEntries.setDisable(!isConnectedToDocument); - boolean canCite = isConnectedToDocument && hasStyle && hasSelectedBibEntry; - boolean cslStyleSelected = preferences.getOpenOfficePreferences().getCurrentStyle() instanceof CitationStyle; - pushEntriesInt.setDisable(!canCite); - pushEntriesEmpty.setDisable(!canCite); - pushEntriesAdvanced.setDisable(!canCite || cslStyleSelected); + boolean cslStyleSelected = openOfficePreferences.getCurrentStyle() instanceof CitationStyle; + pushEntriesInt.setDisable(!isConnectedToDocument); + pushEntriesEmpty.setDisable(!isConnectedToDocument); + pushEntriesAdvanced.setDisable(!isConnectedToDocument || cslStyleSelected); - boolean canRefreshDocument = isConnectedToDocument && hasStyle; + update.setDisable(!isConnectedToDocument); + merge.setDisable(!isConnectedToDocument || cslStyleSelected); + unmerge.setDisable(!isConnectedToDocument || cslStyleSelected); + manageCitations.setDisable(!isConnectedToDocument || cslStyleSelected); - update.setDisable(!canRefreshDocument); - merge.setDisable(!canRefreshDocument || cslStyleSelected); - unmerge.setDisable(!canRefreshDocument || cslStyleSelected); - manageCitations.setDisable(!canRefreshDocument || cslStyleSelected); - - exportCitations.setDisable(!(isConnectedToDocument && hasDatabase) || cslStyleSelected); + exportCitations.setDisable(!isConnectedToDocument || cslStyleSelected); } private void connect() { @@ -427,7 +419,7 @@ private void connect() { protected OOBibBase call() throws BootstrapException, CreationException { updateProgress(ProgressBar.INDETERMINATE_PROGRESS, ProgressBar.INDETERMINATE_PROGRESS); - Path path = Path.of(preferences.getOpenOfficePreferences().getExecutablePath()); + Path path = Path.of(openOfficePreferences.getExecutablePath()); return createBibBase(path); } }; @@ -450,7 +442,7 @@ protected OOBibBase call() throws BootstrapException, CreationException { Throwable ex = connectTask.getException(); LOGGER.error("autodetect failed", ex); switch (ex) { - case UnsatisfiedLinkError unsatisfiedLinkError -> { + case UnsatisfiedLinkError ignored -> { LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", ex); dialogService.showErrorDialogAndWait(Localization.lang("Unable to connect. One possible reason is that JabRef " @@ -511,12 +503,6 @@ private void pushEntries(CitationType citationType, boolean addPageInfo) { } final BibDatabaseContext bibDatabaseContext = stateManager.getActiveDatabase().get(); - if (bibDatabaseContext == null) { - OOError.noDataBaseIsOpenForCiting() - .setTitle(errorDialogTitle) - .showErrorDialog(dialogService); - return; - } List entries = stateManager.getSelectedEntries(); if (entries.isEmpty()) { @@ -553,12 +539,12 @@ private void pushEntries(CitationType citationType, boolean addPageInfo) { } Optional syncOptions = - preferences.getOpenOfficePreferences().getSyncWhenCiting() + openOfficePreferences.getSyncWhenCiting() ? Optional.of(new Update.SyncOptions(getBaseList())) : Optional.empty(); // Sync options are non-null only when "Automatically sync bibliography when inserting citations" is enabled - if (syncOptions.isPresent() && preferences.getOpenOfficePreferences().getSyncWhenCiting()) { + if (syncOptions.isPresent() && openOfficePreferences.getSyncWhenCiting()) { syncOptions.get().setUpdateBibliography(true); } ooBase.guiActionInsertEntry(entries, From d21a45542fdeb018f6d2e1a999c5a80fa9317ae1 Mon Sep 17 00:00:00 2001 From: subhramit Date: Tue, 17 Sep 2024 03:33:23 +0530 Subject: [PATCH 2/9] Use typed exception handling --- .../java/org/jabref/gui/openoffice/OpenOfficePanel.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 1413db39d05..a42c9f225aa 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -442,14 +442,14 @@ protected OOBibBase call() throws BootstrapException, CreationException { Throwable ex = connectTask.getException(); LOGGER.error("autodetect failed", ex); switch (ex) { - case UnsatisfiedLinkError ignored -> { - LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", ex); + case UnsatisfiedLinkError unsatisfiedLinkError -> { + LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", unsatisfiedLinkError); dialogService.showErrorDialogAndWait(Localization.lang("Unable to connect. One possible reason is that JabRef " + "and OpenOffice/LibreOffice are not both running in either 32 bit mode or 64 bit mode.")); } case IOException ioException -> { - LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", ex); + LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", ioException); dialogService.showErrorDialogAndWait(Localization.lang("Could not connect to running OpenOffice/LibreOffice."), Localization.lang("Could not connect to running OpenOffice/LibreOffice.") From 041bf02ee63d20398c74cfaf4c968c2261d1282c Mon Sep 17 00:00:00 2001 From: subhramit Date: Tue, 17 Sep 2024 03:34:46 +0530 Subject: [PATCH 3/9] Rename prefs variable --- src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index a42c9f225aa..7f642a304e1 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -587,12 +587,12 @@ private boolean checkThatEntriesHaveKeys(List entries) { Optional databaseContext = stateManager.getActiveDatabase(); if (citePressed && databaseContext.isPresent()) { // Generate keys - CitationKeyPatternPreferences prefs = preferences.getCitationKeyPatternPreferences(); + CitationKeyPatternPreferences citationKeyPatternPreferences = preferences.getCitationKeyPatternPreferences(); NamedCompound undoCompound = new NamedCompound(Localization.lang("Cite")); for (BibEntry entry : entries) { if (entry.getCitationKey().isEmpty()) { // Generate key - new CitationKeyGenerator(databaseContext.get(), prefs) + new CitationKeyGenerator(databaseContext.get(), citationKeyPatternPreferences) .generateAndSetKey(entry) .ifPresent(change -> undoCompound.addEdit(new UndoableKeyChange(change))); } From f759087e6880fc90e0c23c632e7dc49a4740f0c8 Mon Sep 17 00:00:00 2001 From: subhramit Date: Tue, 17 Sep 2024 04:55:58 +0530 Subject: [PATCH 4/9] Minimize usage of preferences --- .../jabref/gui/openoffice/OpenOfficePanel.java | 17 ++++++++++++----- .../gui/sidepane/SidePaneContentFactory.java | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 7f642a304e1..19196479ba5 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -34,6 +34,7 @@ import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionFactory; import org.jabref.gui.actions.StandardActions; +import org.jabref.gui.frame.ExternalApplicationsPreferences; import org.jabref.gui.help.HelpAction; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.preferences.GuiPreferences; @@ -47,6 +48,7 @@ import org.jabref.logic.help.HelpFile; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.layout.LayoutFormatterPreferences; import org.jabref.logic.openoffice.OpenOfficeFileSearch; import org.jabref.logic.openoffice.OpenOfficePreferences; import org.jabref.logic.openoffice.action.Update; @@ -95,6 +97,8 @@ public class OpenOfficePanel { private final VBox vbox = new VBox(); private final GuiPreferences preferences; + private final OpenOfficePreferences openOfficePreferences; + private final CitationKeyPatternPreferences citationKeyPatternPreferences; private final StateManager stateManager; private final ClipBoardManager clipBoardManager; private final UndoManager undoManager; @@ -103,7 +107,6 @@ public class OpenOfficePanel { private final LibraryTabContainer tabContainer; private final FileUpdateMonitor fileUpdateMonitor; private final BibEntryTypesManager entryTypesManager; - private final OpenOfficePreferences openOfficePreferences; private OOBibBase ooBase; private OOStyle currentStyle; @@ -111,6 +114,10 @@ public class OpenOfficePanel { public OpenOfficePanel(LibraryTabContainer tabContainer, GuiPreferences preferences, + OpenOfficePreferences openOfficePreferences, + ExternalApplicationsPreferences externalApplicationsPreferences, + LayoutFormatterPreferences layoutFormatterPreferences, + CitationKeyPatternPreferences citationKeyPatternPreferences, JournalAbbreviationRepository abbreviationRepository, UiTaskExecutor taskExecutor, DialogService dialogService, @@ -123,12 +130,13 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, this.fileUpdateMonitor = fileUpdateMonitor; this.entryTypesManager = entryTypesManager; this.preferences = preferences; + this.openOfficePreferences = openOfficePreferences; + this.citationKeyPatternPreferences = citationKeyPatternPreferences; this.taskExecutor = taskExecutor; this.dialogService = dialogService; this.stateManager = stateManager; this.clipBoardManager = clipBoardManager; this.undoManager = undoManager; - this.openOfficePreferences = preferences.getOpenOfficePreferences(); this.currentStyle = openOfficePreferences.getCurrentStyle(); ActionFactory factory = new ActionFactory(); @@ -143,7 +151,7 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, manualConnect.setTooltip(new Tooltip(Localization.lang("Manual connect"))); manualConnect.setMaxWidth(Double.MAX_VALUE); - help = factory.createIconButton(StandardActions.HELP, new HelpAction(HelpFile.OPENOFFICE_LIBREOFFICE, dialogService, preferences.getExternalApplicationsPreferences())); + help = factory.createIconButton(StandardActions.HELP, new HelpAction(HelpFile.OPENOFFICE_LIBREOFFICE, dialogService, externalApplicationsPreferences)); help.setMaxWidth(Double.MAX_VALUE); selectDocument = new Button(); @@ -158,7 +166,7 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, loader = new StyleLoader( openOfficePreferences, - preferences.getLayoutFormatterPreferences(), + layoutFormatterPreferences, abbreviationRepository); currentStyleProperty = new SimpleObjectProperty<>(currentStyle); @@ -587,7 +595,6 @@ private boolean checkThatEntriesHaveKeys(List entries) { Optional databaseContext = stateManager.getActiveDatabase(); if (citePressed && databaseContext.isPresent()) { // Generate keys - CitationKeyPatternPreferences citationKeyPatternPreferences = preferences.getCitationKeyPatternPreferences(); NamedCompound undoCompound = new NamedCompound(Localization.lang("Cite")); for (BibEntry entry : entries) { if (entry.getCitationKey().isEmpty()) { diff --git a/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java b/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java index 6d364aab9a1..171fc8b8777 100644 --- a/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java +++ b/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java @@ -67,6 +67,10 @@ public Node create(SidePaneType sidePaneType) { case OPEN_OFFICE -> new OpenOfficePanel( tabContainer, preferences, + preferences.getOpenOfficePreferences(), + preferences.getExternalApplicationsPreferences(), + preferences.getLayoutFormatterPreferences(), + preferences.getCitationKeyPatternPreferences(), abbreviationRepository, (UiTaskExecutor) taskExecutor, dialogService, From 7958e7d37e6fa77c85999ffd24cb37b535d799fc Mon Sep 17 00:00:00 2001 From: subhramit Date: Sun, 22 Sep 2024 06:07:38 +0530 Subject: [PATCH 5/9] Enhanced pre-condition checks --- .../gui/openoffice/OpenOfficePanel.java | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 19196479ba5..f6b87ca3cf9 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -402,23 +402,25 @@ private void connectManually() { } private void updateButtonAvailability() { - boolean isConnected = ooBase != null; - boolean isConnectedToDocument = isConnected && !ooBase.isDocumentConnectionMissing(); - - selectDocument.setDisable(!isConnected); - pushEntries.setDisable(!isConnectedToDocument); - - boolean cslStyleSelected = openOfficePreferences.getCurrentStyle() instanceof CitationStyle; - pushEntriesInt.setDisable(!isConnectedToDocument); - pushEntriesEmpty.setDisable(!isConnectedToDocument); - pushEntriesAdvanced.setDisable(!isConnectedToDocument || cslStyleSelected); - - update.setDisable(!isConnectedToDocument); - merge.setDisable(!isConnectedToDocument || cslStyleSelected); - unmerge.setDisable(!isConnectedToDocument || cslStyleSelected); - manageCitations.setDisable(!isConnectedToDocument || cslStyleSelected); - - exportCitations.setDisable(!isConnectedToDocument || cslStyleSelected); + boolean isConnectedToDocument = (ooBase != null && !ooBase.isDocumentConnectionMissing()); + boolean hasStyle = (currentStyle != null); + boolean hasDatabase = !getBaseList().isEmpty(); + boolean canRefreshDocument = isConnectedToDocument && hasStyle; + boolean canCite = isConnectedToDocument && hasStyle; + boolean cslStyleSelected = currentStyle instanceof CitationStyle; + + selectDocument.setDisable(!isConnectedToDocument); + + pushEntries.setDisable(!(canCite && hasDatabase)); + pushEntriesInt.setDisable(!(canCite && hasDatabase)); + pushEntriesEmpty.setDisable(!(canCite && hasDatabase)); + pushEntriesAdvanced.setDisable(!(canCite && hasDatabase) || cslStyleSelected); + + update.setDisable(!canRefreshDocument); + merge.setDisable(!canRefreshDocument || cslStyleSelected); + unmerge.setDisable(!canRefreshDocument || cslStyleSelected); + manageCitations.setDisable(!canRefreshDocument || cslStyleSelected); + exportCitations.setDisable(!(isConnectedToDocument && hasDatabase) || cslStyleSelected); } private void connect() { @@ -502,23 +504,19 @@ private static CitationType citationTypeFromOptions(boolean withText, boolean in private void pushEntries(CitationType citationType, boolean addPageInfo) { final String errorDialogTitle = Localization.lang("Error pushing entries"); - if (stateManager.getActiveDatabase().isEmpty() - || (stateManager.getActiveDatabase().get().getDatabase() == null)) { + final Optional activeDatabase = stateManager.getActiveDatabase(); + + if (activeDatabase.isEmpty() + || (activeDatabase.get().getDatabase() == null)) { OOError.noDataBaseIsOpenForCiting() .setTitle(errorDialogTitle) .showErrorDialog(dialogService); return; } - final BibDatabaseContext bibDatabaseContext = stateManager.getActiveDatabase().get(); + final BibDatabaseContext bibDatabaseContext = activeDatabase.get(); List entries = stateManager.getSelectedEntries(); - if (entries.isEmpty()) { - OOError.noEntriesSelectedForCitation() - .setTitle(errorDialogTitle) - .showErrorDialog(dialogService); - return; - } if (getOrUpdateTheStyle(errorDialogTitle)) { return; From 68233dd3a0b118b81f3f0eb352f56c4e7285b4e5 Mon Sep 17 00:00:00 2001 From: subhramit Date: Sun, 22 Sep 2024 06:25:29 +0530 Subject: [PATCH 6/9] Merge condition --- .../org/jabref/gui/openoffice/OpenOfficePanel.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index f6b87ca3cf9..bd5fa8f4bc5 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -406,15 +406,15 @@ private void updateButtonAvailability() { boolean hasStyle = (currentStyle != null); boolean hasDatabase = !getBaseList().isEmpty(); boolean canRefreshDocument = isConnectedToDocument && hasStyle; - boolean canCite = isConnectedToDocument && hasStyle; + boolean canCite = isConnectedToDocument && hasStyle && hasDatabase; boolean cslStyleSelected = currentStyle instanceof CitationStyle; selectDocument.setDisable(!isConnectedToDocument); - pushEntries.setDisable(!(canCite && hasDatabase)); - pushEntriesInt.setDisable(!(canCite && hasDatabase)); - pushEntriesEmpty.setDisable(!(canCite && hasDatabase)); - pushEntriesAdvanced.setDisable(!(canCite && hasDatabase) || cslStyleSelected); + pushEntries.setDisable(!canCite); + pushEntriesInt.setDisable(!canCite); + pushEntriesEmpty.setDisable(!canCite); + pushEntriesAdvanced.setDisable(!canCite || cslStyleSelected); update.setDisable(!canRefreshDocument); merge.setDisable(!canRefreshDocument || cslStyleSelected); From 6594375aa6f158093616574b7fea6f0f68cddbb5 Mon Sep 17 00:00:00 2001 From: subhramit Date: Sun, 22 Sep 2024 06:29:07 +0530 Subject: [PATCH 7/9] Reorder flags --- src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index bd5fa8f4bc5..da9f62dce4f 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -405,8 +405,8 @@ private void updateButtonAvailability() { boolean isConnectedToDocument = (ooBase != null && !ooBase.isDocumentConnectionMissing()); boolean hasStyle = (currentStyle != null); boolean hasDatabase = !getBaseList().isEmpty(); - boolean canRefreshDocument = isConnectedToDocument && hasStyle; boolean canCite = isConnectedToDocument && hasStyle && hasDatabase; + boolean canRefreshDocument = isConnectedToDocument && hasStyle; boolean cslStyleSelected = currentStyle instanceof CitationStyle; selectDocument.setDisable(!isConnectedToDocument); From 61316623df80146cc4cebaa3f6911e5b402cf3f3 Mon Sep 17 00:00:00 2001 From: subhramit Date: Mon, 23 Sep 2024 03:42:56 +0530 Subject: [PATCH 8/9] Revert check: entry selection presence --- .../java/org/jabref/gui/openoffice/OpenOfficePanel.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index da9f62dce4f..cc956d3d715 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -518,6 +518,13 @@ private void pushEntries(CitationType citationType, boolean addPageInfo) { List entries = stateManager.getSelectedEntries(); + if (entries.isEmpty()) { + OOError.noEntriesSelectedForCitation() + .setTitle(errorDialogTitle) + .showErrorDialog(dialogService); + return; + } + if (getOrUpdateTheStyle(errorDialogTitle)) { return; } From 2e779213a859556edfadd47582afc282d516051c Mon Sep 17 00:00:00 2001 From: subhramit Date: Mon, 23 Sep 2024 03:46:29 +0530 Subject: [PATCH 9/9] Fix indent --- src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index cc956d3d715..267526d0ad7 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -506,8 +506,7 @@ private void pushEntries(CitationType citationType, boolean addPageInfo) { final Optional activeDatabase = stateManager.getActiveDatabase(); - if (activeDatabase.isEmpty() - || (activeDatabase.get().getDatabase() == null)) { + if (activeDatabase.isEmpty() || (activeDatabase.get().getDatabase() == null)) { OOError.noDataBaseIsOpenForCiting() .setTitle(errorDialogTitle) .showErrorDialog(dialogService);