diff --git a/build.gradle b/build.gradle index 6913fab8cc0..2da6e7d1afd 100644 --- a/build.gradle +++ b/build.gradle @@ -133,7 +133,7 @@ dependencies { compile 'de.saxsys:mvvmfx:1.7.0' compile 'org.fxmisc.easybind:easybind:1.0.3' compile 'org.fxmisc.flowless:flowless:0.6.1' - compile 'org.fxmisc.richtext:richtextfx:0.9.1' + compile 'org.fxmisc.richtext:richtextfx:0.9.2' compile 'com.sibvisions.external.jvxfx:dndtabpane:0.1' compile 'javax.inject:javax.inject:1' compile 'com.jfoenix:jfoenix:8.0.7' @@ -160,11 +160,12 @@ dependencies { compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.2.1' compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.2.1' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' - testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.1' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1' - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1' - testCompile 'org.junit.platform:junit-platform-launcher:1.3.1' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' + testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.2' + testCompile 'org.junit.platform:junit-platform-launcher:1.3.2' + testCompile 'org.junit-pioneer:junit-pioneer:0.3.0' testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1' testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.1' diff --git a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java index 7a58e2895b4..4ac5618f991 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java @@ -1,6 +1,7 @@ package org.jabref.gui.exporter; import org.jabref.gui.BasePanel; +import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; import org.jabref.gui.actions.Actions; import org.jabref.gui.actions.SimpleCommand; @@ -9,23 +10,27 @@ public class SaveAllAction extends SimpleCommand { private final JabRefFrame frame; + private final DialogService dialogService; public SaveAllAction(JabRefFrame frame) { this.frame = frame; + this.dialogService = frame.getDialogService(); } @Override public void execute() { - frame.output(Localization.lang("Saving all libraries...")); + dialogService.notify(Localization.lang("Saving all libraries...")); + for (BasePanel panel : frame.getBasePanelList()) { if (!panel.getBibDatabaseContext().getDatabasePath().isPresent()) { - frame.showBasePanel(panel); - - // TODO: Ask for path + //It will ask a path before saving. + panel.runCommand(Actions.SAVE_AS); + } else { + panel.runCommand(Actions.SAVE); + // TODO: can we find out whether the save was actually done or not? } - panel.runCommand(Actions.SAVE); - // TODO: can we find out whether the save was actually done or not? } - frame.output(Localization.lang("Save all finished.")); + + dialogService.notify(Localization.lang("Save all finished.")); } } diff --git a/src/main/resources/journals/journalList.txt b/src/main/resources/journals/journalList.txt index cdb5e36ab78..167a87d8290 100644 --- a/src/main/resources/journals/journalList.txt +++ b/src/main/resources/journals/journalList.txt @@ -12215,7 +12215,7 @@ Proceedings of the Koninklijke Nederlandse Akademie Van Wetenschappen. Series C: Proceedings of the Latvian Academy of Sciences, Section B: Natural, Exact and Applied Sciences = Proc. Latv. Acad. Sci. Sect. B Proceedings of the Mine Medical Officers Association = Proc. Mine Med. Off. Assoc. Proceedings of the Mine Medical Officers Association of SA = Proc. Mine Med. Off. Assoc. SA -Proceedings of the National academy of Sciences of the United States of America = Proc. Natl. Acad. Sci. U.S.A. +Proceedings of the National Academy of Sciences of the United States of America = Proc. Natl. Acad. Sci. U.S.A. Proceedings of the National Cancer Conference = Proc. Natl. Cancer Conf. Proceedings of the National Science Council, Republic of China. Part B, Life Sciences = Proc. Natl. Sci. Counc. Repub. China B Proceedings of the Nutrition Society = Proc. Nutr. Soc. diff --git a/src/test/java/org/jabref/gui/exporter/SaveAllActionTest.java b/src/test/java/org/jabref/gui/exporter/SaveAllActionTest.java new file mode 100644 index 00000000000..1233d14a72f --- /dev/null +++ b/src/test/java/org/jabref/gui/exporter/SaveAllActionTest.java @@ -0,0 +1,77 @@ +package org.jabref.gui.exporter; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Optional; + +import org.jabref.gui.BasePanel; +import org.jabref.gui.DialogService; +import org.jabref.gui.JabRefFrame; +import org.jabref.gui.actions.Actions; +import org.jabref.logic.l10n.Localization; +import org.jabref.model.database.BibDatabaseContext; + +import org.junit.Before; +import org.junit.Test; + +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class SaveAllActionTest { + + private BasePanel firstPanel = mock(BasePanel.class); + private BasePanel secondPanel = mock(BasePanel.class); + private JabRefFrame jabRefFrame = mock(JabRefFrame.class); + private DialogService dialogService = mock(DialogService.class); + private BibDatabaseContext bibDatabaseContext = mock(BibDatabaseContext.class); + private Optional databasePath = Optional.of(Paths.get("C:\\Users\\John_Doe\\Jabref")); + private SaveAllAction saveAllAction; + + @Before + public void setUp() { + when(firstPanel.getBibDatabaseContext()).thenReturn(bibDatabaseContext); + when(secondPanel.getBibDatabaseContext()).thenReturn(bibDatabaseContext); + when(bibDatabaseContext.getDatabasePath()).thenReturn(databasePath); + + when(jabRefFrame.getBasePanelList()).thenReturn(Arrays.asList(firstPanel, secondPanel)); + when(jabRefFrame.getDialogService()).thenReturn(dialogService); + + saveAllAction = new SaveAllAction(jabRefFrame); + } + + @Test + public void executeShouldRunSaveCommandInEveryPanel() { + doNothing().when(dialogService).notify(anyString()); + + saveAllAction.execute(); + + verify(firstPanel, times(1)).runCommand(Actions.SAVE); + verify(secondPanel, times(1)).runCommand(Actions.SAVE); + } + + @Test + public void executeShouldNotifyAboutSavingProcess() { + when(bibDatabaseContext.getDatabasePath()).thenReturn(databasePath); + + saveAllAction.execute(); + + verify(dialogService, times(1)).notify(Localization.lang("Saving all libraries...")); + verify(dialogService, times(1)).notify(Localization.lang("Save all finished.")); + } + + @Test + public void executeShouldShowSaveAsWindowIfDatabaseNotSelected() { + when(bibDatabaseContext.getDatabasePath()).thenReturn(Optional.empty()); + doNothing().when(dialogService).notify(anyString()); + + saveAllAction.execute(); + + verify(firstPanel, times(1)).runCommand(Actions.SAVE_AS); + verify(secondPanel, times(1)).runCommand(Actions.SAVE_AS); + } +}