From b3f35ec19a2f9383feab1b3faf97109214bdc780 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Sat, 26 Jan 2019 17:52:37 +0100 Subject: [PATCH 01/30] Update snapcraft.yaml Move to snap folder --- .gitignore | 12 ------ .../snapcraft => snap/gui}/jabref.desktop | 2 +- .../gui/jabref.png | Bin snap/snapcraft.yaml | 34 +++++++++++++++++ snapcraft.yaml | 35 ------------------ 5 files changed, 35 insertions(+), 48 deletions(-) rename {buildres/snapcraft => snap/gui}/jabref.desktop (90%) rename buildres/snapcraft/JabRef-icon-256.png => snap/gui/jabref.png (100%) create mode 100644 snap/snapcraft.yaml delete mode 100644 snapcraft.yaml diff --git a/.gitignore b/.gitignore index eef074f6e45..7c7850841ea 100644 --- a/.gitignore +++ b/.gitignore @@ -23,18 +23,6 @@ ui/ jabref.xml *.sonargraph -# Snapcraft - JabRef places the files into buildres/snapcraft -snap/ - - - - - - - - - - # Created by https://www.gitignore.io/api/gradle,java,jabref,intellij,eclipse,netbeans,windows,linux,macos,node,snapcraft ### Eclipse ### diff --git a/buildres/snapcraft/jabref.desktop b/snap/gui/jabref.desktop similarity index 90% rename from buildres/snapcraft/jabref.desktop rename to snap/gui/jabref.desktop index ef63a896d2d..3444b73fc8a 100644 --- a/buildres/snapcraft/jabref.desktop +++ b/snap/gui/jabref.desktop @@ -4,7 +4,7 @@ GenericName=BibTeX Editor Comment=JabRef is an open source bibliography reference manager. The native file format used by JabRef is BibTeX, the standard LaTeX bibliography format. Type=Application Terminal=false -Icon=${SNAP}/meta/gui/JabRef-icon-256.png +Icon=${SNAP}/meta/gui/jabref.png Exec=jabref %U Keywords=bibtex;biblatex;latex;bibliography Categories=Office; diff --git a/buildres/snapcraft/JabRef-icon-256.png b/snap/gui/jabref.png similarity index 100% rename from buildres/snapcraft/JabRef-icon-256.png rename to snap/gui/jabref.png diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000000..6873178bf86 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,34 @@ +name: jabref +version: "git" +version-script: cat build.gradle | grep "^version =" | cut -d'"' -f2 +#icon: snap/gui/icon.png +summary: Bibliography manager +description: JabRef is an open source bibliography reference manager. The native file format used by JabRef is BibTeX, the standard LaTeX bibliography format. + +grade: devel +confinement: strict + +apps: + jabref: + command: desktop-launch java -jar $SNAP/jar/JabRef-$SNAP_VERSION.jar + environment: + JAVA_OPTS: "-Djava.util.prefs.systemRoot=$SNAP_USER_DATA/.java -Djava.util.prefs.userRoot=$SNAP_USER_DATA/.java/.userPrefs" + plugs: + - desktop + - desktop-legacy + - wayland + - unity7 + - home + - network-bind + +parts: + jabref: + plugin: gradle + source: . + stage-packages: + - openjdk-8-jre + - openjfx + - x11-utils + gradle-options: [snapJar] + gradle-output-dir: 'build/releases' + after: [desktop-gtk3] diff --git a/snapcraft.yaml b/snapcraft.yaml deleted file mode 100644 index 0daa48c83c4..00000000000 --- a/snapcraft.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# based on https://github.com/snapcore/snapcraft/blob/master/demos/gradle/snap/snapcraft.yaml - -name: jabref - -# the version string 4.2-dev is replaced by scripts/run-snapcraft.sh with the current version provided in build.gradle -version: '4.2-dev' - -summary: Bibliography manager -icon: buildres/snapcraft/JabRef-icon-256.png -description: JabRef is an open source bibliography reference manager. The native file format used by JabRef is BibTeX, the standard LaTeX bibliography format. - -# only with the following set to stable + strict, we can do a full release - -# see https://snapcraft.io/docs/reference/channels -# stable | devel -grade: devel - -# see https://snapcraft.io/docs/reference/confinement -# strict | devmode -confinement: strict - -apps: - jabref: - command: desktop-launch java -jar $SNAP/jar/JabRef-4.2-dev.jar - plugs: [desktop, desktop-legacy, wayland, unity7, home, network-bind] - desktop: ../buildres/snapcraft/jabref.desktop - -parts: - jabref: - plugin: gradle - source: . - stage-packages: [default-jre, openjfx, x11-utils] - gradle-options: [snapJar] - gradle-output-dir: 'build/releases' - after: [desktop-gtk3] From dd537702493917ca5fcdc3aeb3046c11caea06ce Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Sun, 27 Jan 2019 13:05:12 +0100 Subject: [PATCH 02/30] Fix preferences path: use _JAVA_OPTIONS --- snap/snapcraft.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 6873178bf86..cdc75820ea6 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -12,13 +12,14 @@ apps: jabref: command: desktop-launch java -jar $SNAP/jar/JabRef-$SNAP_VERSION.jar environment: - JAVA_OPTS: "-Djava.util.prefs.systemRoot=$SNAP_USER_DATA/.java -Djava.util.prefs.userRoot=$SNAP_USER_DATA/.java/.userPrefs" + _JAVA_OPTIONS: "-Djava.util.prefs.systemRoot=$SNAP_USER_DATA/.java/etc/.java -Djava.util.prefs.userRoot=$SNAP_USER_DATA/.java/.userPrefs" plugs: - desktop - desktop-legacy - wayland - unity7 - home + - opengl - network-bind parts: From 095b70b7f052a1a6929a75ba18e8b82fd38e99c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 28 Jan 2019 08:38:22 +0100 Subject: [PATCH 03/30] Bump checkstyle from 8.16 to 8.17 (#4620) Bumps [checkstyle](https://github.com/checkstyle/checkstyle) from 8.16 to 8.17. - [Release notes](https://github.com/checkstyle/checkstyle/releases) - [Commits](https://github.com/checkstyle/checkstyle/compare/checkstyle-8.16...checkstyle-8.17) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 94a5e380cab..b3f68a91c8c 100644 --- a/build.gradle +++ b/build.gradle @@ -181,7 +181,7 @@ dependencies { testCompile "org.testfx:testfx-core:4.0.+" testCompile "org.testfx:testfx-junit5:4.0.+" - checkstyle 'com.puppycrawl.tools:checkstyle:8.16' + checkstyle 'com.puppycrawl.tools:checkstyle:8.17' } jacoco { From fbf1cc9a406da6018619887b73506a89e1535f14 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Mon, 28 Jan 2019 18:13:56 +0100 Subject: [PATCH 04/30] snap: disable tests build, add removable media and specify architectures (#4619) * snap: disable tests build, add removable media and specify architectures * Move to gtk2 fixes the dialogs * Add snap ignores to .gitignore * Add source-type: git to enable submodules --- .gitignore | 8 ++++++++ snap/snapcraft.yaml | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 7c7850841ea..39f4c1f4ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,14 @@ status.md # Install4J install4j6/ +# Snap +parts/ +stage/ +prime/ +*.snap +jabref_source.tar.bz2 +snap/.snapcraft/ + # Gradle # generated when `gradlew --gui` is called ui/ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index cdc75820ea6..b26f84fef0d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,18 +1,22 @@ name: jabref version: "git" version-script: cat build.gradle | grep "^version =" | cut -d'"' -f2 -#icon: snap/gui/icon.png +#icon: snap/gui/jabref.png summary: Bibliography manager description: JabRef is an open source bibliography reference manager. The native file format used by JabRef is BibTeX, the standard LaTeX bibliography format. grade: devel confinement: strict +architectures: + - build-on: amd64 + - build-on: i386 + apps: jabref: command: desktop-launch java -jar $SNAP/jar/JabRef-$SNAP_VERSION.jar environment: - _JAVA_OPTIONS: "-Djava.util.prefs.systemRoot=$SNAP_USER_DATA/.java/etc/.java -Djava.util.prefs.userRoot=$SNAP_USER_DATA/.java/.userPrefs" + _JAVA_OPTIONS: "-Duser.home=$SNAP_USER_DATA" plugs: - desktop - desktop-legacy @@ -21,15 +25,17 @@ apps: - home - opengl - network-bind + - removable-media parts: jabref: plugin: gradle source: . + source-type: git stage-packages: - openjdk-8-jre - openjfx - x11-utils - gradle-options: [snapJar] + gradle-options: [snapJar, -xtest] gradle-output-dir: 'build/releases' - after: [desktop-gtk3] + after: [desktop-gtk2] From 33b35f7f65ef0fab14fcf866d48ce8daade7adb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 31 Jan 2019 08:44:05 +0100 Subject: [PATCH 05/30] Bump wiremock from 2.20.0 to 2.21.0 (#4623) Bumps [wiremock](https://github.com/tomakehurst/wiremock) from 2.20.0 to 2.21.0. - [Release notes](https://github.com/tomakehurst/wiremock/releases) - [Changelog](https://github.com/tomakehurst/wiremock/blob/master/release-settings.gradle) - [Commits](https://github.com/tomakehurst/wiremock/compare/2.20.0...2.21.0) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b3f68a91c8c..9d93378e772 100644 --- a/build.gradle +++ b/build.gradle @@ -171,7 +171,7 @@ dependencies { testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1' testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.1' testCompile 'org.mockito:mockito-core:2.23.4' - testCompile 'com.github.tomakehurst:wiremock:2.20.0' + testCompile 'com.github.tomakehurst:wiremock:2.21.0' testCompile 'org.assertj:assertj-swing-junit:3.8.0' testCompile 'org.reflections:reflections:0.9.11' testCompile 'org.xmlunit:xmlunit-core:2.6.2' From 769ebd19e7ed68a511817aa2bc12c2bcdf149446 Mon Sep 17 00:00:00 2001 From: Chelsey Ong <30564248+chelseyong@users.noreply.github.com> Date: Thu, 31 Jan 2019 16:46:20 +0700 Subject: [PATCH 06/30] Fix preview style configuration (#4613) * Modify prefsTab to save the selected preview style in preferences * Fix codacy by changing to equals --- src/main/java/org/jabref/gui/PreviewPanel.java | 9 +++++++-- .../java/org/jabref/gui/preferences/PreviewPrefsTab.java | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/PreviewPanel.java b/src/main/java/org/jabref/gui/PreviewPanel.java index bffcb4e2bd3..95323116271 100644 --- a/src/main/java/org/jabref/gui/PreviewPanel.java +++ b/src/main/java/org/jabref/gui/PreviewPanel.java @@ -62,6 +62,7 @@ public class PreviewPanel extends ScrollPane implements SearchQueryHighlightList private final KeyBindingRepository keyBindingRepository; private String previewStyle; + private CitationStyle citationStyle; private final String defaultPreviewStyle = "Preview"; private Optional basePanel = Optional.empty(); @@ -224,13 +225,14 @@ private void updateLayout(PreviewPreferences previewPreferences, boolean init) { String style = previewPreferences.getCurrentPreviewStyle(); if (previewStyle == null) { previewStyle = style; + CitationStyle.createCitationStyleFromFile(style).ifPresent(cs -> citationStyle = cs); } if (basePanel.isPresent() && !previewStyle.equals(style)) { if (CitationStyle.isCitationStyleFile(style)) { layout = Optional.empty(); CitationStyle.createCitationStyleFromFile(style) - .ifPresent(citationStyle -> { - basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle); + .ifPresent(cs -> { + citationStyle = cs; if (!init) { basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle())); } @@ -299,6 +301,9 @@ public void update() { .doLayout(entry, databaseContext.getDatabase()))); setPreviewLabel(sb.toString()); } else if (basePanel.isPresent() && bibEntry.isPresent()) { + if (citationStyle != null && !previewStyle.equals(defaultPreviewStyle)) { + basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle); + } Future citationStyleWorker = BackgroundTask .wrap(() -> basePanel.get().getCitationStyleCache().getCitationFor(bibEntry.get())) .onRunning(() -> { diff --git a/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java b/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java index 071aa23cd0a..76fc314f1b8 100644 --- a/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java +++ b/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java @@ -264,6 +264,9 @@ public void storeSettings() { .withPreviewCycle(styles) .withPreviewStyle(layout.getText().replace("\n", "__NEWLINE__")) .build(); + if (!chosen.getSelectionModel().isEmpty()) { + previewPreferences = previewPreferences.getBuilder().withPreviewCyclePosition(chosen.getSelectionModel().getSelectedIndex()).build(); + } Globals.prefs.storePreviewPreferences(previewPreferences); // update preview From 629fcc424f7f7dce419b7c1ab3d8984a84c902e5 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 1 Feb 2019 16:08:00 +0100 Subject: [PATCH 07/30] Fix NPE and not on FX Thread in PreviewPrefs Tabs (#4624) * Fix NPE and not on FX Thread in PreviewPrefs Tabs Remove obsolete swing stuff Create proper javafx binding Fixes #4621 Fixes #4622 Fix another issue where the Preview stlye is not set correctly * fix checkstyle Signed-off-by: Siedlerchr * fix copying of entry preview * prevent divide by zero excpetion * Pass task executor as variable Use Background Task add error message improve binding * remove empty line --- src/main/java/org/jabref/gui/JabRefFrame.java | 27 ++-- .../java/org/jabref/gui/PreviewPanel.java | 36 +++-- .../gui/actions/ShowPreferencesAction.java | 8 +- .../gui/preferences/PreferencesDialog.java | 53 ++++--- .../gui/preferences/PreviewPrefsTab.java | 145 +++++++----------- .../preferences/PreviewPreferences.java | 16 +- src/main/resources/l10n/JabRef_en.properties | 2 + 7 files changed, 134 insertions(+), 153 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index b1872641c36..76e14c8e6ce 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -923,24 +923,23 @@ private MenuBar createMenu() { ); options.getItems().addAll( - factory.createMenuItem(StandardActions.SHOW_PREFS, new ShowPreferencesAction(this)), + factory.createMenuItem(StandardActions.SHOW_PREFS, new ShowPreferencesAction(this, Globals.TASK_EXECUTOR)), - new SeparatorMenuItem(), + new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()), - factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction()), - factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction()), - factory.createMenuItem(StandardActions.MANAGE_EXTERNAL_FILETYPES, new EditExternalFileTypesAction()), - factory.createMenuItem(StandardActions.MANAGE_JOURNALS, new ManageJournalsAction()), - factory.createMenuItem(StandardActions.CUSTOMIZE_KEYBINDING, new CustomizeKeyBindingAction()), - factory.createMenuItem(StandardActions.MANAGE_PROTECTED_TERMS, new ManageProtectedTermsAction(this, Globals.protectedTermsLoader)), + factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()), + factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction()), + factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction()), + factory.createMenuItem(StandardActions.MANAGE_EXTERNAL_FILETYPES, new EditExternalFileTypesAction()), + factory.createMenuItem(StandardActions.MANAGE_JOURNALS, new ManageJournalsAction()), + factory.createMenuItem(StandardActions.CUSTOMIZE_KEYBINDING, new CustomizeKeyBindingAction()), + factory.createMenuItem(StandardActions.MANAGE_PROTECTED_TERMS, new ManageProtectedTermsAction(this, Globals.protectedTermsLoader)), - new SeparatorMenuItem(), + new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.MANAGE_CONTENT_SELECTORS, new OldDatabaseCommandWrapper(Actions.MANAGE_SELECTORS, this, Globals.stateManager)), - factory.createMenuItem(StandardActions.CUSTOMIZE_ENTRY_TYPES, new CustomizeEntryAction(this)), - factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this)) - ); + factory.createMenuItem(StandardActions.MANAGE_CONTENT_SELECTORS, new OldDatabaseCommandWrapper(Actions.MANAGE_SELECTORS, this, Globals.stateManager)), + factory.createMenuItem(StandardActions.CUSTOMIZE_ENTRY_TYPES, new CustomizeEntryAction(this)), + factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this))); help.getItems().addAll( factory.createMenuItem(StandardActions.HELP, HelpAction.getMainHelpPageCommand()), diff --git a/src/main/java/org/jabref/gui/PreviewPanel.java b/src/main/java/org/jabref/gui/PreviewPanel.java index 95323116271..ff8d6db01bd 100644 --- a/src/main/java/org/jabref/gui/PreviewPanel.java +++ b/src/main/java/org/jabref/gui/PreviewPanel.java @@ -94,10 +94,10 @@ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, KeyBind this.keyBindingRepository = keyBindingRepository; fileHandler = new NewDroppedFileHandler(dialogService, databaseContext, externalFileTypes, - Globals.prefs.getFilePreferences(), + Globals.prefs.getFilePreferences(), Globals.prefs.getImportFormatPreferences(), Globals.prefs.getUpdateFieldPreferences(), - Globals.getFileUpdateMonitor()); + Globals.getFileUpdateMonitor()); // Set up scroll pane for preview pane setFitToHeight(true); @@ -231,19 +231,19 @@ private void updateLayout(PreviewPreferences previewPreferences, boolean init) { if (CitationStyle.isCitationStyleFile(style)) { layout = Optional.empty(); CitationStyle.createCitationStyleFromFile(style) - .ifPresent(cs -> { - citationStyle = cs; - if (!init) { - basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle())); - } - }); + .ifPresent(cs -> { + citationStyle = cs; + if (!init) { + basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle())); + } + }); previewStyle = style; - } else { - previewStyle = defaultPreviewStyle; - updatePreviewLayout(previewPreferences.getPreviewStyle(), previewPreferences.getLayoutFormatterPreferences()); - if (!init) { - basePanel.get().output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview"))); - } + } + } else { + previewStyle = defaultPreviewStyle; + updatePreviewLayout(previewPreferences.getPreviewStyle(), previewPreferences.getLayoutFormatterPreferences()); + if (!init) { + basePanel.get().output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview"))); } } @@ -301,7 +301,7 @@ public void update() { .doLayout(entry, databaseContext.getDatabase()))); setPreviewLabel(sb.toString()); } else if (basePanel.isPresent() && bibEntry.isPresent()) { - if (citationStyle != null && !previewStyle.equals(defaultPreviewStyle)) { + if ((citationStyle != null) && !previewStyle.equals(defaultPreviewStyle)) { basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle); } Future citationStyleWorker = BackgroundTask @@ -368,11 +368,13 @@ public void close() { private void copyPreviewToClipBoard() { StringBuilder previewStringContent = new StringBuilder(); Document document = previewView.getEngine().getDocument(); - NodeList nodeList = document.getElementsByTagName("*"); + NodeList nodeList = document.getElementsByTagName("html"); + + //Nodelist does not implement iterable for (int i = 0; i < nodeList.getLength(); i++) { Element element = (Element) nodeList.item(i); - previewStringContent.append(element.getNodeValue()).append("\n"); + previewStringContent.append(element.getTextContent()); } ClipboardContent content = new ClipboardContent(); diff --git a/src/main/java/org/jabref/gui/actions/ShowPreferencesAction.java b/src/main/java/org/jabref/gui/actions/ShowPreferencesAction.java index 7c13cbcc250..e6c0a29684c 100644 --- a/src/main/java/org/jabref/gui/actions/ShowPreferencesAction.java +++ b/src/main/java/org/jabref/gui/actions/ShowPreferencesAction.java @@ -2,17 +2,21 @@ import org.jabref.gui.JabRefFrame; import org.jabref.gui.preferences.PreferencesDialog; +import org.jabref.gui.util.TaskExecutor; public class ShowPreferencesAction extends SimpleCommand { private final JabRefFrame jabRefFrame; - public ShowPreferencesAction(JabRefFrame jabRefFrame) { + private final TaskExecutor taskExecutor; + + public ShowPreferencesAction(JabRefFrame jabRefFrame, TaskExecutor taskExecutor) { this.jabRefFrame = jabRefFrame; + this.taskExecutor = taskExecutor; } @Override public void execute() { - PreferencesDialog preferencesDialog = new PreferencesDialog(jabRefFrame); + PreferencesDialog preferencesDialog = new PreferencesDialog(jabRefFrame, taskExecutor); preferencesDialog.showAndWait(); } } diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java index a2571e4e5fd..25837b9b62c 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java @@ -25,6 +25,7 @@ import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.FileDialogConfiguration; +import org.jabref.gui.util.TaskExecutor; import org.jabref.gui.util.ViewModelListCellFactory; import org.jabref.logic.exporter.ExporterFactory; import org.jabref.logic.exporter.SavePreferences; @@ -57,7 +58,7 @@ public class PreferencesDialog extends BaseDialog { private final JabRefPreferences prefs; private final ObservableList preferenceTabs; - public PreferencesDialog(JabRefFrame parent) { + public PreferencesDialog(JabRefFrame parent, TaskExecutor taskExecutor) { setTitle(Localization.lang("JabRef preferences")); getDialogPane().getScene().getStylesheets().add(this.getClass().getResource("PreferencesDialog.css").toExternalForm()); @@ -68,7 +69,7 @@ public PreferencesDialog(JabRefFrame parent) { close(); }); - prefs = JabRefPreferences.getInstance(); + prefs = Globals.prefs; frame = parent; dialogService = frame.getDialogService(); @@ -77,7 +78,7 @@ public PreferencesDialog(JabRefFrame parent) { preferenceTabs.add(new FileTab(dialogService, prefs)); preferenceTabs.add(new TablePrefsTab(prefs)); preferenceTabs.add(new TableColumnsTab(prefs, frame)); - preferenceTabs.add(new PreviewPrefsTab(dialogService, ExternalFileTypes.getInstance())); + preferenceTabs.add(new PreviewPrefsTab(dialogService, ExternalFileTypes.getInstance(), taskExecutor)); preferenceTabs.add(new ExternalTab(frame, this, prefs)); preferenceTabs.add(new GroupsPrefsTab(prefs)); preferenceTabs.add(new EntryEditorPrefsTab(prefs)); @@ -111,8 +112,8 @@ private void construct() { }); tabsList.getSelectionModel().selectFirst(); new ViewModelListCellFactory() - .withText(PrefsTab::getTabName) - .install(tabsList); + .withText(PrefsTab::getTabName) + .install(tabsList); VBox buttonContainer = new VBox(); buttonContainer.setAlignment(Pos.BOTTOM_LEFT); @@ -132,21 +133,19 @@ private void construct() { resetPreferences.setOnAction(e -> resetPreferences()); resetPreferences.setMaxWidth(Double.MAX_VALUE); buttonContainer.getChildren().addAll( - importPreferences, - exportPreferences, - showPreferences, - resetPreferences - ); + importPreferences, + exportPreferences, + showPreferences, + resetPreferences); VBox spacer = new VBox(); spacer.setPrefHeight(10.0); VBox.setVgrow(tabsList, Priority.ALWAYS); VBox.setVgrow(spacer, Priority.SOMETIMES); vBox.getChildren().addAll( - tabsList, - spacer, - buttonContainer - ); + tabsList, + spacer, + buttonContainer); container.setLeft(vBox); @@ -155,16 +154,16 @@ private void construct() { private void resetPreferences() { boolean resetPreferencesConfirmed = dialogService.showConfirmationDialogAndWait( - Localization.lang("Reset preferences"), - Localization.lang("Are you sure you want to reset all settings to default values?"), - Localization.lang("Reset preferences"), - Localization.lang("Cancel")); + Localization.lang("Reset preferences"), + Localization.lang("Are you sure you want to reset all settings to default values?"), + Localization.lang("Reset preferences"), + Localization.lang("Cancel")); if (resetPreferencesConfirmed) { try { prefs.clear(); dialogService.showWarningDialogAndWait(Localization.lang("Reset preferences"), - Localization.lang("You must restart JabRef for this to come into effect.")); + Localization.lang("You must restart JabRef for this to come into effect.")); } catch (BackingStoreException ex) { LOGGER.error("Error while resetting preferences", ex); dialogService.showErrorDialogAndWait(Localization.lang("Reset preferences"), ex); @@ -175,9 +174,9 @@ private void resetPreferences() { private void importPreferences() { FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() - .addExtensionFilter(StandardFileType.XML) - .withDefaultExtension(StandardFileType.XML) - .withInitialDirectory(prefs.setLastPreferencesExportPath()).build(); + .addExtensionFilter(StandardFileType.XML) + .withDefaultExtension(StandardFileType.XML) + .withInitialDirectory(prefs.setLastPreferencesExportPath()).build(); dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> { try { @@ -185,7 +184,7 @@ private void importPreferences() { updateAfterPreferenceChanges(); dialogService.showWarningDialogAndWait(Localization.lang("Import preferences"), - Localization.lang("You must restart JabRef for this to come into effect.")); + Localization.lang("You must restart JabRef for this to come into effect.")); } catch (JabRefException ex) { LOGGER.error("Error while importing preferences", ex); dialogService.showErrorDialogAndWait(Localization.lang("Import preferences"), ex); @@ -230,10 +229,10 @@ public void setValues() { private void exportPreferences() { FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() - .addExtensionFilter(StandardFileType.XML) - .withDefaultExtension(StandardFileType.XML) - .withInitialDirectory(prefs.setLastPreferencesExportPath()) - .build(); + .addExtensionFilter(StandardFileType.XML) + .withDefaultExtension(StandardFileType.XML) + .withInitialDirectory(prefs.setLastPreferencesExportPath()) + .build(); dialogService.showFileSaveDialog(fileDialogConfiguration) .ifPresent(exportFile -> { diff --git a/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java b/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java index 76fc314f1b8..5ace5352e0a 100644 --- a/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java +++ b/src/main/java/org/jabref/gui/preferences/PreviewPrefsTab.java @@ -4,11 +4,9 @@ import java.util.Comparator; import java.util.List; import java.util.Optional; -import java.util.concurrent.ExecutionException; - -import javax.swing.JPanel; -import javax.swing.SwingWorker; +import javafx.beans.binding.Bindings; +import javafx.beans.binding.BooleanBinding; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Node; @@ -28,7 +26,8 @@ import org.jabref.gui.DialogService; import org.jabref.gui.PreviewPanel; import org.jabref.gui.externalfiletype.ExternalFileTypes; -import org.jabref.gui.util.DefaultTaskExecutor; +import org.jabref.gui.util.BackgroundTask; +import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.citationstyle.CitationStyle; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.TestEntry; @@ -38,12 +37,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PreviewPrefsTab extends JPanel implements PrefsTab { +public class PreviewPrefsTab implements PrefsTab { private static final Logger LOGGER = LoggerFactory.getLogger(PreviewPrefsTab.class); - private SwingWorker, Void> discoverCitationStyleWorker; - private final ObservableList availableModel = FXCollections.observableArrayList(); private final ObservableList chosenModel = FXCollections.observableArrayList(); @@ -61,25 +58,24 @@ public class PreviewPrefsTab extends JPanel implements PrefsTab { private final ScrollPane scrollPane = new ScrollPane(layout); private final DialogService dialogService; private final ExternalFileTypes externalFileTypes; + private final TaskExecutor taskExecutor; - public PreviewPrefsTab(DialogService dialogService, ExternalFileTypes externalFileTypes) { + public PreviewPrefsTab(DialogService dialogService, ExternalFileTypes externalFileTypes, TaskExecutor taskExecutor) { this.dialogService = dialogService; this.externalFileTypes = externalFileTypes; + this.taskExecutor = taskExecutor; setupLogic(); setupGui(); } private void setupLogic() { - chosen.getSelectionModel().selectedItemProperty().addListener(event -> { - if (chosen.getSelectionModel().getSelectedIndices().isEmpty()) { - btnLeft.setDisable(true); - btnDown.setDisable(true); - btnUp.setDisable(true); - } - }); - available.getSelectionModel().selectedItemProperty().addListener( - e -> btnRight.setDisable(available.getSelectionModel().getSelectedIndices().isEmpty())); + BooleanBinding nothingSelectedFromChosen = Bindings.isEmpty(chosen.getSelectionModel().getSelectedItems()); + + btnLeft.disableProperty().bind(nothingSelectedFromChosen); + btnDown.disableProperty().bind(nothingSelectedFromChosen); + btnUp.disableProperty().bind(nothingSelectedFromChosen); + btnRight.disableProperty().bind(Bindings.isEmpty(available.getSelectionModel().getSelectedItems())); btnRight.setOnAction(event -> { for (Object object : available.getSelectionModel().getSelectedItems()) { @@ -110,9 +106,9 @@ private void setupLogic() { btnDown.setOnAction(event -> { List newSelectedIndices = new ArrayList<>(); - ObservableList selectedIndices = chosen.getSelectionModel().getSelectedIndices(); + ObservableList selectedIndices = chosen.getSelectionModel().getSelectedIndices(); for (int i = selectedIndices.size() - 1; i >= 0; i--) { - int oldIndex = (int)selectedIndices.get(i); + int oldIndex = selectedIndices.get(i); boolean alreadyTaken = newSelectedIndices.contains(oldIndex + 1); int newIndex = ((oldIndex < (chosenModel.size() - 1)) && !alreadyTaken) ? oldIndex + 1 : oldIndex; chosenModel.add(newIndex, chosenModel.remove(oldIndex)); @@ -122,41 +118,33 @@ private void setupLogic() { }); btnDefault.setOnAction(event -> layout.setText(Globals.prefs.getPreviewPreferences() - .getPreviewStyleDefault() - .replace("__NEWLINE__", "\n"))); + .getPreviewStyleDefault() + .replace("__NEWLINE__", "\n"))); btnTest.setOnAction(event -> { try { - DefaultTaskExecutor.runInJavaFXThread(() -> { - PreviewPanel testPane = new PreviewPanel(null, new BibDatabaseContext(), Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), dialogService, externalFileTypes); - if (chosen.getSelectionModel().getSelectedItems().isEmpty()) { - testPane.setFixedLayout(layout.getText()); - testPane.setEntry(TestEntry.getTestEntry()); - } - else { - int indexStyle = chosen.getSelectionModel().getSelectedIndex(); - PreviewPreferences preferences = Globals.prefs.getPreviewPreferences(); - preferences = new PreviewPreferences(preferences.getPreviewCycle(),indexStyle,preferences.getPreviewPanelDividerPosition(),preferences.isPreviewPanelEnabled(), preferences.getPreviewStyle(),preferences.getPreviewStyleDefault()); - - testPane = new PreviewPanel(JabRefGUI.getMainFrame().getCurrentBasePanel(), new BibDatabaseContext(), Globals.getKeyPrefs(), preferences, dialogService, externalFileTypes); - testPane.setEntry(TestEntry.getTestEntry()); - testPane.updateLayout(preferences); - } - DialogPane pane = new DialogPane(); - pane.setContent(testPane); - - dialogService.showCustomDialogAndWait(Localization.lang("Preview"), pane, ButtonType.OK); + PreviewPanel testPane = new PreviewPanel(null, new BibDatabaseContext(), Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), dialogService, externalFileTypes); + if (chosen.getSelectionModel().getSelectedItems().isEmpty()) { + testPane.setFixedLayout(layout.getText()); + testPane.setEntry(TestEntry.getTestEntry()); + } else { + int indexStyle = chosen.getSelectionModel().getSelectedIndex(); + PreviewPreferences preferences = Globals.prefs.getPreviewPreferences(); + preferences = new PreviewPreferences(preferences.getPreviewCycle(), indexStyle, preferences.getPreviewPanelDividerPosition(), preferences.isPreviewPanelEnabled(), preferences.getPreviewStyle(), preferences.getPreviewStyleDefault()); + + testPane = new PreviewPanel(JabRefGUI.getMainFrame().getCurrentBasePanel(), new BibDatabaseContext(), Globals.getKeyPrefs(), preferences, dialogService, externalFileTypes); + testPane.setEntry(TestEntry.getTestEntry()); + testPane.updateLayout(preferences); + } - }); + DialogPane pane = new DialogPane(); + pane.setContent(testPane); + dialogService.showCustomDialogAndWait(Localization.lang("Preview"), pane, ButtonType.OK); } catch (StringIndexOutOfBoundsException exception) { LOGGER.warn("Parsing error.", exception); - - DefaultTaskExecutor.runInJavaFXThread(()-> dialogService.showErrorDialogAndWait(Localization.lang("Parsing error"), - Localization.lang("Parsing error") + ": " + Localization.lang("illegal backslash expression"), - exception)); - + dialogService.showErrorDialogAndWait(Localization.lang("Parsing error"), Localization.lang("Parsing error") + ": " + Localization.lang("illegal backslash expression"), exception); } }); } @@ -167,9 +155,9 @@ private void setupGui() { btnLeft.setPrefSize(80, 20); btnUp.setPrefSize(80, 20); btnDown.setPrefSize(80, 20); - vBox.getChildren().addAll(new Label(""), new Label(""), new Label(""), new Label(""), new Label(""), - new Label(""), new Label(""), btnRight, btnLeft, new Label(""), new Label(""), new Label(""), - btnUp, btnDown); + vBox.getChildren().addAll(new Label(""), new Label(""), new Label(""), new Label(""), new Label(""), + new Label(""), new Label(""), btnRight, btnLeft, new Label(""), new Label(""), new Label(""), + btnUp, btnDown); Label currentPreview = new Label(Localization.lang("Current Preview")); currentPreview.getStyleClass().add("sectionHeader"); gridPane.add(currentPreview, 1, 1); @@ -182,6 +170,7 @@ private void setupGui() { gridPane.add(scrollPane, 1, 9); } + @Override public Node getBuilder() { return gridPane; } @@ -212,39 +201,17 @@ public void setValues() { availableModel.add(Localization.lang("Preview")); } - btnLeft.setDisable(!chosen.getSelectionModel().getSelectedItems().isEmpty()); - btnRight.setDisable(available.getSelectionModel().getSelectedIndices().isEmpty()); - btnUp.setDisable(!chosen.getSelectionModel().getSelectedIndices().isEmpty()); - btnDown.setDisable(!chosen.getSelectionModel().getSelectedIndices().isEmpty()); - - if (discoverCitationStyleWorker != null) { - discoverCitationStyleWorker.cancel(true); - } - - discoverCitationStyleWorker = new SwingWorker, Void>() { - @Override - protected List doInBackground() throws Exception { - return CitationStyle.discoverCitationStyles(); - } - - @Override - public void done() { - if (this.isCancelled()) { - return; - } - try { - get().stream() - .filter(style -> !previewPreferences.getPreviewCycle().contains(style.getFilePath())) - .sorted(Comparator.comparing(CitationStyle::getTitle)) - .forEach(availableModel::add); - - btnRight.setDisable(availableModel.isEmpty()); - } catch (InterruptedException | ExecutionException e) { - LOGGER.error("something went wrong while adding the discovered CitationStyles to the list "); - } - } - }; - discoverCitationStyleWorker.execute(); + BackgroundTask.wrap(() -> CitationStyle.discoverCitationStyles()) + .onSuccess(value -> { + value.stream() + .filter(style -> !previewPreferences.getPreviewCycle().contains(style.getFilePath())) + .sorted(Comparator.comparing(CitationStyle::getTitle)) + .forEach(availableModel::add); + }) + .onFailure(ex -> { + LOGGER.error("something went wrong while adding the discovered CitationStyles to the list ", ex); + dialogService.showErrorDialogAndWait(Localization.lang("Error adding discovered CitationStyles"), ex); + }).executeWith(taskExecutor); layout.setText(Globals.prefs.getPreviewPreferences().getPreviewStyle().replace("__NEWLINE__", "\n")); } @@ -252,6 +219,10 @@ public void done() { @Override public void storeSettings() { List styles = new ArrayList<>(); + + if (chosenModel.isEmpty()) { + chosenModel.add(Localization.lang("Preview")); + } for (Object obj : chosenModel) { if (obj instanceof CitationStyle) { styles.add(((CitationStyle) obj).getFilePath()); @@ -260,10 +231,10 @@ public void storeSettings() { } } PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences() - .getBuilder() - .withPreviewCycle(styles) - .withPreviewStyle(layout.getText().replace("\n", "__NEWLINE__")) - .build(); + .getBuilder() + .withPreviewCycle(styles) + .withPreviewStyle(layout.getText().replace("\n", "__NEWLINE__")) + .build(); if (!chosen.getSelectionModel().isEmpty()) { previewPreferences = previewPreferences.getBuilder().withPreviewCyclePosition(chosen.getSelectionModel().getSelectedIndex()).build(); } diff --git a/src/main/java/org/jabref/preferences/PreviewPreferences.java b/src/main/java/org/jabref/preferences/PreviewPreferences.java index 835b4fd7da7..c8d879e1a70 100644 --- a/src/main/java/org/jabref/preferences/PreviewPreferences.java +++ b/src/main/java/org/jabref/preferences/PreviewPreferences.java @@ -8,7 +8,7 @@ public class PreviewPreferences { private final List previewCycle; - private int previewCyclePosition; + private final int previewCyclePosition; private final Number previewPanelDividerPosition; private final boolean previewPanelEnabled; private final String previewStyle; @@ -60,6 +60,7 @@ public LayoutFormatterPreferences getLayoutFormatterPreferences() { } public static class Builder { + private List previewCycle; private int previeCyclePosition; private Number previewPanelDividerPosition; @@ -67,7 +68,6 @@ public static class Builder { private String previewStyle; private final String previewStyleDefault; - public Builder(PreviewPreferences previewPreferences) { this.previewCycle = previewPreferences.getPreviewCycle(); this.previeCyclePosition = previewPreferences.getPreviewCyclePosition(); @@ -83,11 +83,15 @@ public Builder withPreviewCycle(List previewCycle) { } public Builder withPreviewCyclePosition(int position) { - previeCyclePosition = position; - while (previeCyclePosition < 0) { - previeCyclePosition += previewCycle.size(); + if (previewCycle.isEmpty()) { + previeCyclePosition = 0; + } else { + previeCyclePosition = position; + while (previeCyclePosition < 0) { + previeCyclePosition += previewCycle.size(); + } + previeCyclePosition %= previewCycle.size(); } - previeCyclePosition %= previewCycle.size(); return this; } diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 5b5e6925b1e..6e5e0d1a2af 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2216,3 +2216,5 @@ File\ extension\:=File extension\: Export\ format\ name\:=Export format name\: Cleared\ connection\ settings=Cleared connection settings + +Error\ adding\ discovered\ CitationStyles=Error adding discovered CitationStyles From 6fe2ebecc2fcc37f36c433f0af0bd5013ac8a7a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 4 Feb 2019 13:12:17 +0100 Subject: [PATCH 08/30] Bump mysql-connector-java from 8.0.14 to 8.0.15 (#4627) Bumps [mysql-connector-java](https://github.com/mysql/mysql-connector-j) from 8.0.14 to 8.0.15. - [Release notes](https://github.com/mysql/mysql-connector-j/releases) - [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.0/CHANGES) - [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.14...8.0.15) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9d93378e772..93cc91533ab 100644 --- a/build.gradle +++ b/build.gradle @@ -120,7 +120,7 @@ dependencies { antlr4 'org.antlr:antlr4:4.7.2' compile 'org.antlr:antlr4-runtime:4.7.2' - compile 'mysql:mysql-connector-java:8.0.14' + compile 'mysql:mysql-connector-java:8.0.15' compile 'org.postgresql:postgresql:42.2.5' From a0c2e04eae23659d04f5526e7bd9259e8b63ea23 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 4 Feb 2019 13:13:22 +0100 Subject: [PATCH 09/30] Bump mockito-core from 2.23.4 to 2.24.0 (#4626) Bumps [mockito-core](https://github.com/mockito/mockito) from 2.23.4 to 2.24.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v2.23.4...v2.24.0) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 93cc91533ab..593a8d5ea02 100644 --- a/build.gradle +++ b/build.gradle @@ -170,7 +170,7 @@ dependencies { 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' - testCompile 'org.mockito:mockito-core:2.23.4' + testCompile 'org.mockito:mockito-core:2.24.0' testCompile 'com.github.tomakehurst:wiremock:2.21.0' testCompile 'org.assertj:assertj-swing-junit:3.8.0' testCompile 'org.reflections:reflections:0.9.11' From 1f792b6bcdcdbf0a2a4fb3602a93a005c1b6489d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 8 Feb 2019 08:51:00 +0100 Subject: [PATCH 10/30] Bump junit-jupiter-engine from 5.3.2 to 5.4.0 (#4635) Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.3.2 to 5.4.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.3.2...r5.4.0) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 593a8d5ea02..aab40c01189 100644 --- a/build.gradle +++ b/build.gradle @@ -163,7 +163,7 @@ dependencies { 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.jupiter:junit-jupiter-engine:5.4.0' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.2' testCompile 'org.junit.platform:junit-platform-launcher:1.3.2' From 6b52f5239fdfb3e060165a62e71ab6f3a886b481 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 8 Feb 2019 08:51:20 +0100 Subject: [PATCH 11/30] Bump junit-jupiter-api from 5.3.2 to 5.4.0 (#4639) Bumps [junit-jupiter-api](https://github.com/junit-team/junit5) from 5.3.2 to 5.4.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.3.2...r5.4.0) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index aab40c01189..9c37bcd6e97 100644 --- a/build.gradle +++ b/build.gradle @@ -161,7 +161,7 @@ dependencies { compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.3.0' compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.3.0' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0' testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.2' From 8d26b24f221da225e39c0b09d1721667e29d7c79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 8 Feb 2019 08:51:54 +0100 Subject: [PATCH 12/30] Bump junit-platform-launcher from 1.3.2 to 1.4.0 (#4636) Bumps [junit-platform-launcher](https://github.com/junit-team/junit5) from 1.3.2 to 1.4.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/commits) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9c37bcd6e97..9971084fe12 100644 --- a/build.gradle +++ b/build.gradle @@ -165,7 +165,7 @@ dependencies { testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.2' - testCompile 'org.junit.platform:junit-platform-launcher:1.3.2' + testCompile 'org.junit.platform:junit-platform-launcher:1.4.0' testCompile 'org.junit-pioneer:junit-pioneer:0.3.0' testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1' From 6bb14a35bf1eff3401f4bdb109e3e4dd504aab66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 8 Feb 2019 08:53:42 +0100 Subject: [PATCH 13/30] Bump junit-vintage-engine from 5.3.2 to 5.4.0 (#4637) Bumps [junit-vintage-engine](https://github.com/junit-team/junit5) from 5.3.2 to 5.4.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.3.2...r5.4.0) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9971084fe12..a667aea6be4 100644 --- a/build.gradle +++ b/build.gradle @@ -164,7 +164,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0' testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0' - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.2' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.4.0' testCompile 'org.junit.platform:junit-platform-launcher:1.4.0' testCompile 'org.junit-pioneer:junit-pioneer:0.3.0' From c30896f8e93e5c5819d61dccd3a93588f8ff13de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 8 Feb 2019 08:54:12 +0100 Subject: [PATCH 14/30] Bump junit-jupiter-params from 5.3.2 to 5.4.0 (#4638) Bumps [junit-jupiter-params](https://github.com/junit-team/junit5) from 5.3.2 to 5.4.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.3.2...r5.4.0) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a667aea6be4..827d519782f 100644 --- a/build.gradle +++ b/build.gradle @@ -162,7 +162,7 @@ dependencies { compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.3.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0' - testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2' + testCompile 'org.junit.jupiter:junit-jupiter-params:5.4.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.4.0' testCompile 'org.junit.platform:junit-platform-launcher:1.4.0' From 891a93ba9ebfa1a820e60093a53eb45e0386e892 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 8 Feb 2019 10:39:13 +0100 Subject: [PATCH 15/30] Use 'junit-jupiter' aggregator module (#4640) --- build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 827d519782f..9464b267ca7 100644 --- a/build.gradle +++ b/build.gradle @@ -161,9 +161,7 @@ dependencies { compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.3.0' compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.3.0' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0' - testCompile 'org.junit.jupiter:junit-jupiter-params:5.4.0' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0' + testImplementation 'org.junit.jupiter:junit-jupiter:5.4.0' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.4.0' testCompile 'org.junit.platform:junit-platform-launcher:1.4.0' From 935d625e2dcf58b8d6157567f12bd349accaff1e Mon Sep 17 00:00:00 2001 From: Ronak Lakhotia Date: Fri, 8 Feb 2019 22:24:21 +0800 Subject: [PATCH 16/30] Add Integrity check for books with edition reported as 1 --- .../java/org/jabref/logic/integrity/EditionChecker.java | 8 +++++++- .../org/jabref/logic/integrity/IntegrityCheckTest.java | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/integrity/EditionChecker.java b/src/main/java/org/jabref/logic/integrity/EditionChecker.java index 54a1869bfe2..072c7a4a4f1 100644 --- a/src/main/java/org/jabref/logic/integrity/EditionChecker.java +++ b/src/main/java/org/jabref/logic/integrity/EditionChecker.java @@ -14,6 +14,7 @@ public class EditionChecker implements ValueChecker { private static final Predicate FIRST_LETTER_CAPITALIZED = Pattern.compile("^[A-Z]").asPredicate(); private static final Predicate ONLY_NUMERALS_OR_LITERALS = Pattern.compile("^([0-9]+|[^0-9].+)$") .asPredicate(); + private static final String FIRST_EDITION = "1"; private final BibDatabaseContext bibDatabaseContextEdition; @@ -44,10 +45,15 @@ public Optional checkValue(String value) { } //BibTeX - if (!bibDatabaseContextEdition.isBiblatexMode() && !FIRST_LETTER_CAPITALIZED.test(value.trim())) { + if (!bibDatabaseContextEdition.isBiblatexMode() && !FIRST_LETTER_CAPITALIZED.test(value.trim()) && + !value.equals(FIRST_EDITION)) { return Optional.of(Localization.lang("should have the first letter capitalized")); } + if (value.equals(FIRST_EDITION)) { + return Optional.of(Localization.lang("edition of book reported as just 1")); + } + return Optional.empty(); } } diff --git a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java index 54a1d715e99..8fb2bb73aeb 100644 --- a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java +++ b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java @@ -86,6 +86,7 @@ void testEditionChecks() { withMode(createContext("edition", "Third, revised and expanded edition"), BibDatabaseMode.BIBLATEX)); assertCorrect(withMode(createContext("edition", "Edition 2000"), BibDatabaseMode.BIBLATEX)); assertWrong(withMode(createContext("edition", "2nd"), BibDatabaseMode.BIBLATEX)); + assertWrong(createContext("edition", "1")); } @Test From 6da731c6c8da9a75af613144cae058a0303c7cc4 Mon Sep 17 00:00:00 2001 From: Ronak Lakhotia Date: Fri, 8 Feb 2019 23:00:27 +0800 Subject: [PATCH 17/30] Edit localization file --- src/main/resources/l10n/JabRef_en.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 6e5e0d1a2af..f8291d55412 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1986,6 +1986,7 @@ Sumatra\ Reader=Sumatra Reader shared=shared should\ contain\ an\ integer\ or\ a\ literal=should contain an integer or a literal should\ have\ the\ first\ letter\ capitalized=should have the first letter capitalized +edition\ of\ book\ reported\ as\ just\ 1=edition of book reported as just 1 Tools=Tools What\'s\ new\ in\ this\ version?=What\'s new in this version? Want\ to\ help?=Want to help? From 71e02379a068756a3885aa22161337255683fca3 Mon Sep 17 00:00:00 2001 From: Akash Deep Date: Sat, 9 Feb 2019 20:06:12 +0530 Subject: [PATCH 18/30] Fix for issue 4641: Remove usage of TempDirectory extension from junit-pioneer (#4644) * Removed the TempDirectory extension from junit-pioneer with the built in extension of junit 5.4 * Removed unused import --- build.gradle | 4 ---- .../externalfiles/AutoSetFileLinksUtilTest.java | 6 ++---- .../gui/fieldeditors/LinkedFileViewModelTest.java | 6 ++---- .../ManageJournalAbbreviationsViewModelTest.java | 6 ++---- .../gui/util/FileDialogConfigurationTest.java | 8 +++----- .../jabref/logic/cleanup/CleanupWorkerTest.java | 14 ++++++-------- .../jabref/logic/cleanup/MoveFilesCleanupTest.java | 6 ++---- .../jabref/logic/cleanup/RenamePdfCleanupTest.java | 14 ++++++-------- .../logic/exporter/BibTeXMLExporterTestFiles.java | 6 ++---- .../jabref/logic/exporter/CsvExportFormatTest.java | 12 +++++------- .../logic/exporter/DocBook5ExporterTest.java | 6 ++---- .../org/jabref/logic/exporter/ExporterTest.java | 10 ++++------ .../logic/exporter/HtmlExportFormatTest.java | 6 ++---- .../logic/exporter/MSBibExportFormatTestFiles.java | 6 ++---- .../logic/exporter/ModsExportFormatTest.java | 6 ++---- .../logic/exporter/ModsExportFormatTestFiles.java | 6 ++---- .../logic/exporter/MsBibExportFormatTest.java | 6 ++---- .../org/jabref/logic/exporter/XmpExporterTest.java | 12 +++++------- .../jabref/logic/integrity/IntegrityCheckTest.java | 6 ++---- .../protectedterms/ProtectedTermsListTest.java | 6 ++---- .../protectedterms/ProtectedTermsLoaderTest.java | 14 ++++++-------- .../logic/util/io/CiteKeyBasedFileFinderTest.java | 6 ++---- .../org/jabref/logic/util/io/FileUtilTest.java | 8 +++----- .../org/jabref/logic/xmp/XmpUtilWriterTest.java | 8 +++----- 24 files changed, 69 insertions(+), 119 deletions(-) diff --git a/build.gradle b/build.gradle index 9464b267ca7..fc1c0fec81d 100644 --- a/build.gradle +++ b/build.gradle @@ -165,7 +165,6 @@ dependencies { testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.4.0' testCompile 'org.junit.platform:junit-platform-launcher:1.4.0' - 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' testCompile 'org.mockito:mockito-core:2.24.0' @@ -190,9 +189,6 @@ dependencyUpdates { outputFormatter = "json" } -//We have to use this as long as junit-pioneer has no official release -dependencyUpdates.revision = 'integration' - // We have some dependencies which cannot be updated due to various reasons. dependencyUpdates.resolutionStrategy = { componentSelection { rules -> diff --git a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java index ae1b46fe557..54be381f4b5 100644 --- a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java +++ b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java @@ -16,15 +16,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) public class AutoSetFileLinksUtilTest { private final FilePreferences fileDirPrefs = mock(FilePreferences.class); @@ -34,7 +32,7 @@ public class AutoSetFileLinksUtilTest { private final BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); @BeforeEach - public void setUp(@TempDirectory.TempDir Path folder) throws Exception { + public void setUp(@TempDir Path folder) throws Exception { Path path = folder.resolve("CiteKey.pdf"); Files.createFile(path); entry.setCiteKey("CiteKey"); diff --git a/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java b/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java index a2fcce655cf..7a7893c6d79 100644 --- a/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java +++ b/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java @@ -17,8 +17,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -31,7 +30,6 @@ import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) class LinkedFileViewModelTest { private Path tempFile; @@ -43,7 +41,7 @@ class LinkedFileViewModelTest { private DialogService dialogService; @BeforeEach - void setUp(@TempDirectory.TempDir Path tempFolder) throws Exception { + void setUp(@TempDir Path tempFolder) throws Exception { entry = new BibEntry(); databaseContext = new BibDatabaseContext(); taskExecutor = mock(TaskExecutor.class); diff --git a/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java b/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java index 77e7d20cc36..96f00ed4065 100644 --- a/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java +++ b/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java @@ -23,8 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.jabref.logic.util.OS.NEWLINE; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -37,7 +36,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) class ManageJournalAbbreviationsViewModelTest { private ManageJournalAbbreviationsViewModel viewModel; @@ -50,7 +48,7 @@ class ManageJournalAbbreviationsViewModelTest { private DialogService dialogService; @BeforeEach - void setUpViewModel(@TempDirectory.TempDir Path tempFolder) throws Exception { + void setUpViewModel(@TempDir Path tempFolder) throws Exception { abbreviationPreferences = mock(JournalAbbreviationPreferences.class); PreferencesService preferences = mock(PreferencesService.class); when(preferences.getJournalAbbreviationPreferences()).thenReturn(abbreviationPreferences); diff --git a/src/test/java/org/jabref/gui/util/FileDialogConfigurationTest.java b/src/test/java/org/jabref/gui/util/FileDialogConfigurationTest.java index 2a19e5593a6..5f608f0ef4a 100644 --- a/src/test/java/org/jabref/gui/util/FileDialogConfigurationTest.java +++ b/src/test/java/org/jabref/gui/util/FileDialogConfigurationTest.java @@ -12,16 +12,14 @@ import org.jabref.logic.util.StandardFileType; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; -@ExtendWith(TempDirectory.class) class FileDialogConfigurationTest { @Test - void testWithValidDirectoryString(@TempDirectory.TempDir Path folder) { + void testWithValidDirectoryString(@TempDir Path folder) { String tempFolder = folder.toAbsolutePath().toString(); FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() @@ -31,7 +29,7 @@ void testWithValidDirectoryString(@TempDirectory.TempDir Path folder) { } @Test - void testWithValidDirectoryPath(@TempDirectory.TempDir Path tempFolder) { + void testWithValidDirectoryPath(@TempDir Path tempFolder) { FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() .withInitialDirectory(tempFolder).build(); diff --git a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java index 567dffd1f6a..46431376144 100644 --- a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java +++ b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java @@ -34,8 +34,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -44,14 +43,13 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) class CleanupWorkerTest { private final CleanupPreset emptyPreset = new CleanupPreset(EnumSet.noneOf(CleanupPreset.CleanupStep.class)); private CleanupWorker worker; @BeforeEach - void setUp(@TempDirectory.TempDir Path bibFolder) throws IOException { + void setUp(@TempDir Path bibFolder) throws IOException { Path path = bibFolder.resolve("ARandomlyNamedFolder"); Files.createDirectory(path); @@ -82,7 +80,7 @@ void cleanupNullEntryThrowsException() { } @Test - void cleanupDoesNothingByDefault(@TempDirectory.TempDir Path bibFolder) throws IOException { + void cleanupDoesNothingByDefault(@TempDir Path bibFolder) throws IOException { BibEntry entry = new BibEntry(); entry.setCiteKey("Toot"); entry.setField("pdf", "aPdfFile"); @@ -220,7 +218,7 @@ void cleanupFixFileLinksMovesSingleDescriptionToLink() { } @Test - void cleanupMoveFilesMovesFileFromSubfolder(@TempDirectory.TempDir Path bibFolder) throws IOException { + void cleanupMoveFilesMovesFileFromSubfolder(@TempDir Path bibFolder) throws IOException { CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.MOVE_PDF); Path path = bibFolder.resolve("AnotherRandomlyNamedFolder"); @@ -238,7 +236,7 @@ void cleanupMoveFilesMovesFileFromSubfolder(@TempDirectory.TempDir Path bibFolde } @Test - void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDirectory.TempDir Path bibFolder) throws IOException { + void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDir Path bibFolder) throws IOException { CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.MAKE_PATHS_RELATIVE); Path path = bibFolder.resolve("AnotherRandomlyNamedFile"); @@ -254,7 +252,7 @@ void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDirectory.TempDir Pa } @Test - void cleanupRenamePdfRenamesRelativeFile(@TempDirectory.TempDir Path bibFolder) throws IOException { + void cleanupRenamePdfRenamesRelativeFile(@TempDir Path bibFolder) throws IOException { CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.RENAME_PDF); Path path = bibFolder.resolve("AnotherRandomlyNamedFile.tmp"); diff --git a/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java index 9e9d21bfbd0..bfb0501b11a 100644 --- a/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java @@ -17,8 +17,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -26,7 +25,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) class MoveFilesCleanupTest { private Path defaultFileFolder; @@ -36,7 +34,7 @@ class MoveFilesCleanupTest { private FilePreferences filePreferences; @BeforeEach - void setUp(@TempDirectory.TempDir Path bibFolder) throws IOException { + void setUp(@TempDir Path bibFolder) throws IOException { // The folder where the files should be moved to defaultFileFolder = bibFolder.resolve("pdf"); Files.createDirectory(defaultFileFolder); diff --git a/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java index eb027f824d0..53449106ff4 100644 --- a/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java @@ -17,14 +17,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) class RenamePdfCleanupTest { private BibEntry entry; @@ -33,7 +31,7 @@ class RenamePdfCleanupTest { private RenamePdfCleanup cleanup; @BeforeEach - void setUp(@TempDirectory.TempDir Path testFolder) { + void setUp(@TempDir Path testFolder) { Path path = testFolder.resolve("test.bib"); MetaData metaData = new MetaData(); BibDatabaseContext context = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults()); @@ -51,7 +49,7 @@ void setUp(@TempDirectory.TempDir Path testFolder) { * Test for #466 */ @Test - void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDirectory.TempDir Path testFolder) throws IOException { + void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDir Path testFolder) throws IOException { Path path = testFolder.resolve("toot.tmp"); Files.createFile(path); @@ -66,7 +64,7 @@ void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDirectory.TempDi } @Test - void cleanupRenamePdfRenamesWithMultipleFiles(@TempDirectory.TempDir Path testFolder) throws IOException { + void cleanupRenamePdfRenamesWithMultipleFiles(@TempDir Path testFolder) throws IOException { Path path = testFolder.resolve("Toot.tmp"); Files.createFile(path); @@ -84,7 +82,7 @@ void cleanupRenamePdfRenamesWithMultipleFiles(@TempDirectory.TempDir Path testFo } @Test - void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDirectory.TempDir Path testFolder) throws IOException { + void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDir Path testFolder) throws IOException { Path path = testFolder.resolve("Toot.tmp"); Files.createFile(path); @@ -100,7 +98,7 @@ void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDirectory.TempDir Pat } @Test - void cleanupRenamePdfRenamesFileInSameFolder(@TempDirectory.TempDir Path testFolder) throws IOException { + void cleanupRenamePdfRenamesFileInSameFolder(@TempDir Path testFolder) throws IOException { Path path = testFolder.resolve("Toot.pdf"); Files.createFile(path); LinkedFile fileField = new LinkedFile("", "Toot.pdf", "PDF"); diff --git a/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java b/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java index 85051a17351..a1513a6ee9f 100644 --- a/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java +++ b/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java @@ -18,10 +18,9 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junitpioneer.jupiter.TempDirectory; import org.mockito.Answers; import org.xmlunit.builder.Input; import org.xmlunit.builder.Input.Builder; @@ -32,7 +31,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class BibTeXMLExporterTestFiles { private static Path resourceDir; @@ -52,7 +50,7 @@ public static Stream fileNames() throws IOException, URISyntaxException } @BeforeEach - public void setUp(@TempDirectory.TempDir Path testFolder) throws Exception { + public void setUp(@TempDir Path testFolder) throws Exception { databaseContext = new BibDatabaseContext(); charset = StandardCharsets.UTF_8; bibtexmlExportFormat = new BibTeXMLExporter(); diff --git a/src/test/java/org/jabref/logic/exporter/CsvExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/CsvExportFormatTest.java index a408b035221..1450f3d8295 100644 --- a/src/test/java/org/jabref/logic/exporter/CsvExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/CsvExportFormatTest.java @@ -17,14 +17,12 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class CsvExportFormatTest { public BibDatabaseContext databaseContext; @@ -51,7 +49,7 @@ public void tearDown() { } @Test - public void testPerformExportForSingleAuthor(@TempDirectory.TempDir Path testFolder) throws Exception { + public void testPerformExportForSingleAuthor(@TempDir Path testFolder) throws Exception { Path path = testFolder.resolve("ThisIsARandomlyNamedFile"); BibEntry entry = new BibEntry(); @@ -68,7 +66,7 @@ public void testPerformExportForSingleAuthor(@TempDirectory.TempDir Path testFol } @Test - public void testPerformExportForMultipleAuthors(@TempDirectory.TempDir Path testFolder) throws Exception { + public void testPerformExportForMultipleAuthors(@TempDir Path testFolder) throws Exception { Path path = testFolder.resolve("ThisIsARandomlyNamedFile"); BibEntry entry = new BibEntry(); @@ -85,7 +83,7 @@ public void testPerformExportForMultipleAuthors(@TempDirectory.TempDir Path test } @Test - public void testPerformExportForSingleEditor(@TempDirectory.TempDir Path testFolder) throws Exception { + public void testPerformExportForSingleEditor(@TempDir Path testFolder) throws Exception { Path path = testFolder.resolve("ThisIsARandomlyNamedFile"); File tmpFile = path.toFile(); BibEntry entry = new BibEntry(); @@ -102,7 +100,7 @@ public void testPerformExportForSingleEditor(@TempDirectory.TempDir Path testFol } @Test - public void testPerformExportForMultipleEditors(@TempDirectory.TempDir Path testFolder) throws Exception { + public void testPerformExportForMultipleEditors(@TempDir Path testFolder) throws Exception { Path path = testFolder.resolve("ThisIsARandomlyNamedFile"); File tmpFile = path.toFile(); BibEntry entry = new BibEntry(); diff --git a/src/test/java/org/jabref/logic/exporter/DocBook5ExporterTest.java b/src/test/java/org/jabref/logic/exporter/DocBook5ExporterTest.java index a97c72ef463..cd0fa728187 100644 --- a/src/test/java/org/jabref/logic/exporter/DocBook5ExporterTest.java +++ b/src/test/java/org/jabref/logic/exporter/DocBook5ExporterTest.java @@ -20,8 +20,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import org.xmlunit.builder.Input; import org.xmlunit.builder.Input.Builder; @@ -32,7 +31,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class DocBook5ExporterTest { public BibDatabaseContext databaseContext; @@ -68,7 +66,7 @@ public void setUp() throws URISyntaxException { } @Test - public void testPerformExportForSingleEntry(@TempDirectory.TempDir Path testFolder) throws Exception { + public void testPerformExportForSingleEntry(@TempDir Path testFolder) throws Exception { Path path = testFolder.resolve("ThisIsARandomlyNamedFile"); diff --git a/src/test/java/org/jabref/logic/exporter/ExporterTest.java b/src/test/java/org/jabref/logic/exporter/ExporterTest.java index 67c7087f8da..ef33a47b167 100644 --- a/src/test/java/org/jabref/logic/exporter/ExporterTest.java +++ b/src/test/java/org/jabref/logic/exporter/ExporterTest.java @@ -16,16 +16,14 @@ import org.jabref.model.entry.BibEntry; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junitpioneer.jupiter.TempDirectory; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class ExporterTest { public BibDatabaseContext databaseContext; @@ -56,7 +54,7 @@ private static Stream exportFormats() { @ParameterizedTest @MethodSource("exportFormats") - public void testExportingEmptyDatabaseYieldsEmptyFile(Exporter exportFormat, String name, @TempDirectory.TempDir Path testFolder) throws Exception { + public void testExportingEmptyDatabaseYieldsEmptyFile(Exporter exportFormat, String name, @TempDir Path testFolder) throws Exception { Path tmpFile = testFolder.resolve("ARandomlyNamedFile"); Files.createFile(tmpFile); exportFormat.export(databaseContext, tmpFile, charset, entries); @@ -65,7 +63,7 @@ public void testExportingEmptyDatabaseYieldsEmptyFile(Exporter exportFormat, Str @ParameterizedTest @MethodSource("exportFormats") - public void testExportingNullDatabaseThrowsNPE(Exporter exportFormat, String name, @TempDirectory.TempDir Path testFolder) { + public void testExportingNullDatabaseThrowsNPE(Exporter exportFormat, String name, @TempDir Path testFolder) { assertThrows(NullPointerException.class, () -> { Path tmpFile = testFolder.resolve("ARandomlyNamedFile"); Files.createFile(tmpFile); @@ -75,7 +73,7 @@ public void testExportingNullDatabaseThrowsNPE(Exporter exportFormat, String nam @ParameterizedTest @MethodSource("exportFormats") - public void testExportingNullEntriesThrowsNPE(Exporter exportFormat, String name, @TempDirectory.TempDir Path testFolder) { + public void testExportingNullEntriesThrowsNPE(Exporter exportFormat, String name, @TempDir Path testFolder) { assertThrows(NullPointerException.class, () -> { Path tmpFile = testFolder.resolve("ARandomlyNamedFile"); Files.createFile(tmpFile); diff --git a/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java index 28067d99bde..3fa8628adba 100644 --- a/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java @@ -16,14 +16,12 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class HtmlExportFormatTest { public BibDatabaseContext databaseContext; public Charset charset; @@ -55,7 +53,7 @@ public void tearDown() { } @Test - public void emitWellFormedHtml(@TempDirectory.TempDir Path testFolder) throws Exception { + public void emitWellFormedHtml(@TempDir Path testFolder) throws Exception { Path path = testFolder.resolve("ThisIsARandomlyNamedFile"); exportFormat.export(databaseContext, path, charset, entries); List lines = Files.readAllLines(path); diff --git a/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java b/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java index e1de292326a..1a5da06af9b 100644 --- a/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java +++ b/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java @@ -18,10 +18,9 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junitpioneer.jupiter.TempDirectory; import org.mockito.Answers; import org.xmlunit.builder.Input; import org.xmlunit.builder.Input.Builder; @@ -32,7 +31,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class MSBibExportFormatTestFiles { private static Path resourceDir; @@ -53,7 +51,7 @@ static Stream fileNames() throws IOException, URISyntaxException { } @BeforeEach - void setUp(@TempDirectory.TempDir Path testFolder) throws Exception { + void setUp(@TempDir Path testFolder) throws Exception { databaseContext = new BibDatabaseContext(); charset = StandardCharsets.UTF_8; msBibExportFormat = new MSBibExporter(); diff --git a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java index 2d797d4e8de..65ae6465295 100644 --- a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java @@ -14,14 +14,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class ModsExportFormatTest { public Charset charset; @@ -38,7 +36,7 @@ public void setUp() throws Exception { } @Test - public final void exportForNoEntriesWritesNothing(@TempDirectory.TempDir Path tempFile) throws Exception { + public final void exportForNoEntriesWritesNothing(@TempDir Path tempFile) throws Exception { Path file = tempFile.resolve("ThisIsARandomlyNamedFile"); Files.createFile(file); modsExportFormat.export(databaseContext, tempFile, charset, Collections.emptyList()); diff --git a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java index 009c9f461ac..3834d7895d9 100644 --- a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java +++ b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java @@ -18,10 +18,9 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junitpioneer.jupiter.TempDirectory; import org.mockito.Answers; import org.mockito.Mockito; import org.xmlunit.builder.Input; @@ -33,7 +32,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) public class ModsExportFormatTestFiles { private static Path resourceDir; @@ -57,7 +55,7 @@ public static Stream fileNames() throws Exception { } @BeforeEach - public void setUp(@TempDirectory.TempDir Path testFolder) throws Exception { + public void setUp(@TempDir Path testFolder) throws Exception { databaseContext = new BibDatabaseContext(); charset = StandardCharsets.UTF_8; modsExportFormat = new ModsExporter(); diff --git a/src/test/java/org/jabref/logic/exporter/MsBibExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/MsBibExportFormatTest.java index 103d7c4996b..9ddbe119d73 100644 --- a/src/test/java/org/jabref/logic/exporter/MsBibExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/MsBibExportFormatTest.java @@ -13,12 +13,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; -@ExtendWith(TempDirectory.class) public class MsBibExportFormatTest { public BibDatabaseContext databaseContext; @@ -33,7 +31,7 @@ public void setUp() throws Exception { } @Test - public final void testPerformExportWithNoEntry(@TempDirectory.TempDir Path tempFile) throws IOException, SaveException { + public final void testPerformExportWithNoEntry(@TempDir Path tempFile) throws IOException, SaveException { Path path = tempFile.resolve("ThisIsARandomlyNamedFile"); Files.createFile(path); List entries = Collections.emptyList(); diff --git a/src/test/java/org/jabref/logic/exporter/XmpExporterTest.java b/src/test/java/org/jabref/logic/exporter/XmpExporterTest.java index d06fc91e374..d24b3725624 100644 --- a/src/test/java/org/jabref/logic/exporter/XmpExporterTest.java +++ b/src/test/java/org/jabref/logic/exporter/XmpExporterTest.java @@ -18,15 +18,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) public class XmpExporterTest { private Exporter exporter; @@ -48,7 +46,7 @@ public void setUp() { } @Test - public void exportSingleEntry(@TempDirectory.TempDir Path testFolder) throws Exception { + public void exportSingleEntry(@TempDir Path testFolder) throws Exception { Path file = testFolder.resolve("ThisIsARandomlyNamedFile"); Files.createFile(file); @@ -76,7 +74,7 @@ public void exportSingleEntry(@TempDirectory.TempDir Path testFolder) throws Exc } @Test - public void writeMultipleEntriesInASingleFile(@TempDirectory.TempDir Path testFolder) throws Exception { + public void writeMultipleEntriesInASingleFile(@TempDir Path testFolder) throws Exception { Path file = testFolder.resolve("ThisIsARandomlyNamedFile"); Files.createFile(file); @@ -128,7 +126,7 @@ public void writeMultipleEntriesInASingleFile(@TempDirectory.TempDir Path testFo } @Test - public void writeMultipleEntriesInDifferentFiles(@TempDirectory.TempDir Path testFolder) throws Exception { + public void writeMultipleEntriesInDifferentFiles(@TempDir Path testFolder) throws Exception { Path file = testFolder.resolve("split"); Files.createFile(file); @@ -194,7 +192,7 @@ public void writeMultipleEntriesInDifferentFiles(@TempDirectory.TempDir Path tes } @Test - public void exportSingleEntryWithPrivacyFilter(@TempDirectory.TempDir Path testFolder) throws Exception { + public void exportSingleEntryWithPrivacyFilter(@TempDir Path testFolder) throws Exception { when(xmpPreferences.getXmpPrivacyFilter()).thenReturn(Arrays.asList("author")); when(xmpPreferences.isUseXMPPrivacyFilter()).thenReturn(true); diff --git a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java index 54a1d715e99..8884604b67c 100644 --- a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java +++ b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java @@ -23,8 +23,7 @@ import org.jabref.model.metadata.MetaData; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mockito; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -32,7 +31,6 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) class IntegrityCheckTest { @Test @@ -220,7 +218,7 @@ void testFileChecks() { } @Test - void fileCheckFindsFilesRelativeToBibFile(@TempDirectory.TempDir Path testFolder) throws IOException { + void fileCheckFindsFilesRelativeToBibFile(@TempDir Path testFolder) throws IOException { Path bibFile = testFolder.resolve("lit.bib"); Files.createFile(bibFile); Path pdfFile = testFolder.resolve("file.pdf"); diff --git a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsListTest.java b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsListTest.java index c8fbdf7f7e6..54109db5c86 100644 --- a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsListTest.java +++ b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsListTest.java @@ -8,21 +8,19 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -@ExtendWith(TempDirectory.class) public class ProtectedTermsListTest { private ProtectedTermsList internalList; private ProtectedTermsList externalList; @BeforeEach - public void setUp(@TempDirectory.TempDir Path temporaryFolder) throws IOException { + public void setUp(@TempDir Path temporaryFolder) throws IOException { Path path = temporaryFolder.resolve("ThisIsARandomlyNamedFile"); Files.createFile(path); String tempFileName = path.toString(); diff --git a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java index 0cc24dc3b8a..b08c1c3546d 100644 --- a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java +++ b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java @@ -14,14 +14,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -@ExtendWith(TempDirectory.class) class ProtectedTermsLoaderTest { private ProtectedTermsLoader loader; @@ -166,7 +164,7 @@ void testDoNotLoadTheSameInternalListTwice() { } @Test - void testAddNewTermListAddsList(@TempDirectory.TempDir Path tempDir) { + void testAddNewTermListAddsList(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), @@ -176,7 +174,7 @@ void testAddNewTermListAddsList(@TempDirectory.TempDir Path tempDir) { } @Test - void testAddNewTermListNewListInList(@TempDirectory.TempDir Path tempDir) { + void testAddNewTermListNewListInList(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), @@ -187,7 +185,7 @@ void testAddNewTermListNewListInList(@TempDirectory.TempDir Path tempDir) { } @Test - void testRemoveTermList(@TempDirectory.TempDir Path tempDir) { + void testRemoveTermList(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), @@ -197,7 +195,7 @@ void testRemoveTermList(@TempDirectory.TempDir Path tempDir) { } @Test - void testRemoveTermListReduceTheCount(@TempDirectory.TempDir Path tempDir) { + void testRemoveTermListReduceTheCount(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), @@ -209,7 +207,7 @@ void testRemoveTermListReduceTheCount(@TempDirectory.TempDir Path tempDir) { } @Test - void testAddNewTermListSetsCorrectDescription(@TempDirectory.TempDir Path tempDir) { + void testAddNewTermListSetsCorrectDescription(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), diff --git a/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java b/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java index 70c8ea51941..67e5147665e 100644 --- a/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java +++ b/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java @@ -12,12 +12,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; -@ExtendWith(TempDirectory.class) class CiteKeyBasedFileFinderTest { private BibEntry entry; @@ -28,7 +26,7 @@ class CiteKeyBasedFileFinderTest { private Path pdfFile; @BeforeEach - void setUp(@TempDirectory.TempDir Path temporaryFolder) throws IOException { + void setUp(@TempDir Path temporaryFolder) throws IOException { entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setCiteKey("HipKro03"); diff --git a/src/test/java/org/jabref/logic/util/io/FileUtilTest.java b/src/test/java/org/jabref/logic/util/io/FileUtilTest.java index 4103e8b7d23..386ab268e08 100644 --- a/src/test/java/org/jabref/logic/util/io/FileUtilTest.java +++ b/src/test/java/org/jabref/logic/util/io/FileUtilTest.java @@ -18,8 +18,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -29,7 +28,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; -@ExtendWith(TempDirectory.class) class FileUtilTest { private final Path nonExistingTestPath = Paths.get("nonExistingTestPath"); private Path existingTestFile; @@ -38,7 +36,7 @@ class FileUtilTest { private Path rootDir; @BeforeEach - void setUpViewModel(@TempDirectory.TempDir Path temporaryFolder) throws IOException { + void setUpViewModel(@TempDir Path temporaryFolder) throws IOException { rootDir = temporaryFolder; Path subDir = rootDir.resolve("1"); Files.createDirectory(subDir); @@ -322,7 +320,7 @@ void testRenameFileWithFromFileExistAndOtherToFileExist() { } @Test - void testRenameFileSuccessful(@TempDirectory.TempDir Path otherTemporaryFolder) { + void testRenameFileSuccessful(@TempDir Path otherTemporaryFolder) { // Be careful. This "otherTemporaryFolder" is the same as the "temporaryFolder" // in the @BeforeEach method. Path temp = Paths.get(otherTemporaryFolder.resolve("123").toString()); diff --git a/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java b/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java index f3d57c6bfae..4de6513ca4f 100644 --- a/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java +++ b/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java @@ -15,14 +15,12 @@ import org.apache.pdfbox.pdmodel.PDPage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) class XmpUtilWriterTest { private static BibEntry olly2018; @@ -94,7 +92,7 @@ void setUp() { * Test for writing a PDF file with a single DublinCore metadata entry. */ @Test - void testWriteXmp(@TempDirectory.TempDir Path tempDir) throws IOException, TransformerException { + void testWriteXmp(@TempDir Path tempDir) throws IOException, TransformerException { Path pdfFile = this.createDefaultFile("JabRef_writeSingle.pdf", tempDir); @@ -118,7 +116,7 @@ void testWriteXmp(@TempDirectory.TempDir Path tempDir) throws IOException, Trans * Test, which writes multiple metadata entries to a PDF and reads them again to test the size. */ @Test - void testWriteMultipleBibEntries(@TempDirectory.TempDir Path tempDir) throws IOException, TransformerException { + void testWriteMultipleBibEntries(@TempDir Path tempDir) throws IOException, TransformerException { Path pdfFile = this.createDefaultFile("JabRef_writeMultiple.pdf", tempDir); From 8e7b1f952ea08f2719f48f8eea7b2a1129865845 Mon Sep 17 00:00:00 2001 From: shubhamatlani Date: Sun, 10 Feb 2019 03:28:22 +0530 Subject: [PATCH 19/30] Automatically created groups with Field to group by as entrytype (#4539) (#4555) * Filter automatically created groups by entrytype (#4539) * Address review comments - replace for loop with stream (#4539) * return value in case of unknown entry type (#4539) --- CHANGELOG.md | 1 + src/main/java/org/jabref/model/entry/BibEntry.java | 11 ++++++++++- .../org/jabref/model/groups/WordKeywordGroup.java | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c29a663c2b..26e4ebbf307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We updated updated the Related Articles tab to accept JSON from the new version of the Mr. DLib service - We added an option in the preference dialog box that allows user to choose behavior after dragging and dropping files in Entry Editor. [#4356](https://github.com/JabRef/jabref/issues/4356) - We added the ability to have an export preference where previously "File"-->"Export"/"Export selected entries" would not save the user's preference[#4495](https://github.com/JabRef/jabref/issues/4495) +- For automatically created groups, added ability to filter groups by entry type. [#4539](https://github.com/JabRef/jabref/issues/4539) - We added the ability to add field names from the Preferences Dialog [#4546](https://github.com/JabRef/jabref/issues/4546) - We added the ability change the column widths directly in the main table. [#4546](https://github.com/JabRef/jabref/issues/4546) - We added the ability to execute default action in dialog by using with Ctrl + Enter combination [#4496](https://github.com/JabRef/jabref/issues/4496) diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index bfd5182bd11..4e133b759cf 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -792,7 +792,7 @@ private void invalidateFieldCache(String fieldName) { } public Optional getLatexFreeField(String name) { - if (!hasField(name)) { + if (!hasField(name) && !TYPE_HEADER.equals(name)) { return Optional.empty(); } else if (latexFreeFields.containsKey(name)) { return Optional.ofNullable(latexFreeFields.get(toLowerCase(name))); @@ -801,6 +801,15 @@ public Optional getLatexFreeField(String name) { Optional citeKey = getCiteKeyOptional(); latexFreeFields.put(name, citeKey.get()); return citeKey; + } else if (TYPE_HEADER.equals(name)) { + Optional entryType = EntryTypes.getType(getType(), BibDatabaseMode.BIBLATEX); + if (entryType.isPresent()) { + String entryName = entryType.get().getName(); + latexFreeFields.put(name, entryName); + return Optional.of(entryName); + } else { + return Optional.of(StringUtil.capitalizeFirst(getType())); + } } else { String latexFreeField = LatexToUnicodeAdapter.format(getField(name).get()).intern(); latexFreeFields.put(name, latexFreeField); diff --git a/src/main/java/org/jabref/model/groups/WordKeywordGroup.java b/src/main/java/org/jabref/model/groups/WordKeywordGroup.java index 5353f8e65af..35a5912c332 100644 --- a/src/main/java/org/jabref/model/groups/WordKeywordGroup.java +++ b/src/main/java/org/jabref/model/groups/WordKeywordGroup.java @@ -6,10 +6,15 @@ import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; +import org.jabref.model.EntryTypes; import org.jabref.model.FieldChange; +import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.EntryType; import org.jabref.model.entry.KeywordList; import org.jabref.model.strings.StringUtil; @@ -113,6 +118,12 @@ public boolean contains(BibEntry entry) { private Set getFieldContentAsWords(BibEntry entry) { if (onlySplitWordsAtSeparator) { + if (BibEntry.TYPE_HEADER.equals(searchField)) { + Optional entryType = EntryTypes.getType(entry.getType(), BibDatabaseMode.BIBLATEX); + if (entryType.isPresent()) { + return searchWords.stream().filter(sw -> entryType.get().getName().equals(sw)).collect(Collectors.toSet()); + } + } return entry.getField(searchField) .map(content -> KeywordList.parse(content, keywordSeparator).toStringList()) .orElse(Collections.emptySet()); From b858a2c02ab8c97f817a2ab4c96cd0ff110db6ae Mon Sep 17 00:00:00 2001 From: Ronak Lakhotia Date: Sun, 10 Feb 2019 20:41:13 +0800 Subject: [PATCH 20/30] Reorder conditional checks --- .../org/jabref/logic/integrity/EditionChecker.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/logic/integrity/EditionChecker.java b/src/main/java/org/jabref/logic/integrity/EditionChecker.java index 072c7a4a4f1..c382fe7eab1 100644 --- a/src/main/java/org/jabref/logic/integrity/EditionChecker.java +++ b/src/main/java/org/jabref/logic/integrity/EditionChecker.java @@ -39,21 +39,20 @@ public Optional checkValue(String value) { return Optional.empty(); } + if (value.equals(FIRST_EDITION)) { + return Optional.of(Localization.lang("edition of book reported as just 1")); + } + //biblatex if (bibDatabaseContextEdition.isBiblatexMode() && !ONLY_NUMERALS_OR_LITERALS.test(value.trim())) { return Optional.of(Localization.lang("should contain an integer or a literal")); } //BibTeX - if (!bibDatabaseContextEdition.isBiblatexMode() && !FIRST_LETTER_CAPITALIZED.test(value.trim()) && - !value.equals(FIRST_EDITION)) { + if (!bibDatabaseContextEdition.isBiblatexMode() && !FIRST_LETTER_CAPITALIZED.test(value.trim())) { return Optional.of(Localization.lang("should have the first letter capitalized")); } - if (value.equals(FIRST_EDITION)) { - return Optional.of(Localization.lang("edition of book reported as just 1")); - } - return Optional.empty(); } } From 8520833e684aa9e305dd8745e45696ffd6d984fb Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 10 Feb 2019 13:47:48 +0100 Subject: [PATCH 21/30] Remove old code for PDF import (#4634) * Remove old code for PDF import * Fix tests * Update Docbook5ExportFormat.xml * Fix tests * Fix checkstyle --- .../jabref/gui/DuplicateResolverDialog.java | 4 +- .../java/org/jabref/gui/DuplicateSearch.java | 4 +- src/main/java/org/jabref/gui/EntryType.fxml | 76 +-- src/main/java/org/jabref/gui/JabRefFrame.java | 26 +- .../java/org/jabref/gui/PreviewPanel.java | 21 +- .../java/org/jabref/gui/SidePaneManager.java | 8 +- .../ResolveDuplicateLabelDialog.java | 2 +- .../jabref/gui/copyfiles/CopyFilesTask.java | 1 - .../jabref/gui/entryeditor/EntryEditor.java | 28 +- .../org/jabref/gui/entryeditor/SourceTab.java | 2 +- .../exporter/CreateModifyExporterDialog.fxml | 76 +-- .../CreateModifyExporterDialogView.java | 8 +- .../CreateModifyExporterDialogViewModel.java | 13 +- .../jabref/gui/exporter/ExportCommand.java | 4 +- .../exporter/ExportCustomizationDialog.fxml | 39 +- .../ExportCustomizationDialogViewModel.java | 3 +- .../gui/exporter/ExportToClipboardAction.java | 12 +- .../gui/exporter/ExporterViewModel.java | 3 - .../gui/exporter/SaveDatabaseAction.java | 4 +- .../gui/externalfiles/DroppedFileHandler.java | 568 ------------------ .../ExternalFilesEntryLinker.java | 20 +- .../gui/externalfiles/FindFullTextAction.java | 10 +- .../FindUnlinkedFilesDialog.java | 96 +-- .../gui/externalfiles/ImportHandler.java | 113 ++++ .../externalfiles/NewDroppedFileHandler.java | 152 ----- .../externalfiletype/ExternalFileTypes.java | 3 +- .../EntryFromExternalFileCreator.java | 36 -- .../gui/importer/EntryFromFileCreator.java | 186 ------ .../importer/EntryFromFileCreatorManager.java | 202 ------- .../gui/importer/EntryFromPDFCreator.java | 62 -- .../gui/importer/ImportInspectionDialog.java | 11 +- .../gui/importer/UnlinkedFilesCrawler.java | 5 +- .../org/jabref/gui/maintable/MainTable.java | 38 +- .../PersistenceVisualStateTable.java | 2 +- .../gui/openoffice/AdvancedCiteDialog.fxml | 41 +- .../openoffice/AdvancedCiteDialogView.java | 1 - .../openoffice/CitationEntryViewModel.java | 1 - .../DetectOpenOfficeInstallation.java | 10 +- .../gui/openoffice/ManageCitationsDialog.fxml | 29 +- .../openoffice/ManageCitationsDialogView.java | 4 +- .../ManageCitationsDialogViewModel.java | 8 +- .../gui/openoffice/ManualConnectDialog.fxml | 68 ++- .../openoffice/ManualConnectDialogView.java | 5 +- .../ManualConnectDialogViewModel.java | 10 +- .../org/jabref/gui/openoffice/OOBibBase.java | 444 +++++++------- .../gui/openoffice/OpenOfficePanel.java | 135 ++--- .../gui/openoffice/StyleSelectDialog.fxml | 60 +- .../gui/openoffice/StyleSelectDialogView.java | 51 +- .../StyleSelectDialogViewModel.java | 15 +- .../openoffice/StyleSelectItemViewModel.java | 1 - .../gui/preferences/ImportSettingsTab.java | 60 -- .../gui/preferences/PreferencesDialog.java | 44 +- .../gui/preferences/PreviewPrefsTab.java | 4 +- .../gui/preferences/TableColumnsTab.java | 94 ++- .../java/org/jabref/gui/util/BaseDialog.java | 6 +- .../jabref/gui/util/FileFilterConverter.java | 23 +- .../org/jabref/gui/util/ZipFileChooser.java | 2 +- .../comparator/ReadStatusFieldComparator.java | 1 - .../logic/exporter/ExporterFactory.java | 2 +- .../logic/exporter/TemplateExporter.java | 11 +- .../ExternalFilesContentImporter.java | 11 +- .../importer/fileformat/BibtexParser.java | 3 +- .../importer/fileformat/MedlineImporter.java | 2 +- .../fileformat/MedlinePlainImporter.java | 2 +- .../fileformat/PdfContentImporter.java | 3 + .../layout/format/CreateDocBook4Authors.java | 2 - .../layout/format/CreateDocBook5Authors.java | 2 - .../layout/format/CreateDocBook5Editors.java | 2 - .../layout/format/DocBookAuthorFormatter.java | 13 +- .../jabref/logic/openoffice/OOBibStyle.java | 3 +- .../openoffice/OpenOfficePreferences.java | 6 +- .../org/jabref/logic/util/io/FileUtil.java | 4 +- .../org/jabref/logic/xmp/XmpUtilReader.java | 7 +- .../java/org/jabref/model/entry/BibEntry.java | 4 +- .../org/jabref/model/entry/LinkedFile.java | 8 + .../org/jabref/model/util/FileHelper.java | 2 +- .../org/jabref/pdfimport/ImportDialog.java | 235 -------- .../org/jabref/pdfimport/PdfFileFilter.java | 28 - .../org/jabref/pdfimport/PdfImporter.java | 256 -------- .../jabref/preferences/JabRefPreferences.java | 31 +- .../preferences/PreferencesService.java | 4 +- src/main/resources/l10n/JabRef_en.properties | 45 -- .../architecture/TestArchitectureTests.java | 1 - .../EntryFromFileCreatorManagerTest.java | 85 --- .../gui/importer/EntryFromPDFCreatorTest.java | 59 -- .../org/jabref/logic/TypedBibEntryTest.java | 4 +- .../logic/exporter/DocBook5ExporterTest.java | 6 +- .../importer/fileformat/BibtexParserTest.java | 2 +- .../fileformat/PdfContentImporterTest.java | 15 +- .../PdfContentImporterTestFiles.java | 8 +- .../org/jabref/logic/layout/LayoutTest.java | 2 +- .../pdf/EntryAnnotationImporterTest.java | 2 +- .../jabref/logic/xmp/XmpUtilReaderTest.java | 15 +- .../jabref/logic/xmp/XmpUtilWriterTest.java | 8 +- .../model/database/BibDatabaseTest.java | 2 +- .../logic/exporter/Docbook5ExportFormat.xml | 2 +- 96 files changed, 970 insertions(+), 2882 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/externalfiles/DroppedFileHandler.java create mode 100644 src/main/java/org/jabref/gui/externalfiles/ImportHandler.java delete mode 100644 src/main/java/org/jabref/gui/externalfiles/NewDroppedFileHandler.java delete mode 100644 src/main/java/org/jabref/gui/importer/EntryFromExternalFileCreator.java delete mode 100644 src/main/java/org/jabref/gui/importer/EntryFromFileCreator.java delete mode 100644 src/main/java/org/jabref/gui/importer/EntryFromFileCreatorManager.java delete mode 100644 src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java delete mode 100644 src/main/java/org/jabref/pdfimport/ImportDialog.java delete mode 100644 src/main/java/org/jabref/pdfimport/PdfFileFilter.java delete mode 100644 src/main/java/org/jabref/pdfimport/PdfImporter.java delete mode 100644 src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java delete mode 100644 src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java diff --git a/src/main/java/org/jabref/gui/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/DuplicateResolverDialog.java index cb34df3d202..0be0d823c83 100644 --- a/src/main/java/org/jabref/gui/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/DuplicateResolverDialog.java @@ -68,7 +68,7 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { second = new ButtonType(Localization.lang("Remove entry from import"), ButtonData.APPLY); both = new ButtonType(Localization.lang("Keep both"), ButtonData.APPLY); me = new MergeEntries(one, two, Localization.lang("Old entry"), - Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); + Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); break; case DUPLICATE_SEARCH_WITH_EXACT: first = new ButtonType(Localization.lang("Keep left"), ButtonData.APPLY); @@ -84,7 +84,7 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { second = new ButtonType(Localization.lang("Do not import entry"), ButtonData.APPLY); both = new ButtonType(Localization.lang("Import and keep old entry"), ButtonData.APPLY); me = new MergeEntries(one, two, Localization.lang("Old entry"), - Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); + Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); break; } if (removeExactVisible) { diff --git a/src/main/java/org/jabref/gui/DuplicateSearch.java b/src/main/java/org/jabref/gui/DuplicateSearch.java index 476b3f70276..9e9921f741a 100644 --- a/src/main/java/org/jabref/gui/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/DuplicateSearch.java @@ -127,7 +127,7 @@ private void askResolveStrategy(DuplicateSearchResult result, BibEntry first, Bi DuplicateResolverResult resolverResult = dialog.showAndWait().orElse(DuplicateResolverResult.BREAK); if ((resolverResult == DuplicateResolverResult.KEEP_LEFT) - || (resolverResult == DuplicateResolverResult.AUTOREMOVE_EXACT)) { + || (resolverResult == DuplicateResolverResult.AUTOREMOVE_EXACT)) { result.remove(second); if (resolverResult == DuplicateResolverResult.AUTOREMOVE_EXACT) { autoRemoveExactDuplicates.set(true); // Remember choice @@ -167,7 +167,7 @@ private void handleDuplicates(DuplicateSearchResult result) { } dialogService.notify(Localization.lang("Duplicates found") + ": " + duplicateCount.get() + ' ' - + Localization.lang("pairs processed") + ": " + result.getDuplicateCount()); + + Localization.lang("pairs processed") + ": " + result.getDuplicateCount()); compoundEdit.end(); panel.getUndoManager().addEdit(compoundEdit); diff --git a/src/main/java/org/jabref/gui/EntryType.fxml b/src/main/java/org/jabref/gui/EntryType.fxml index 7fb864fdf78..0ed5f37b502 100644 --- a/src/main/java/org/jabref/gui/EntryType.fxml +++ b/src/main/java/org/jabref/gui/EntryType.fxml @@ -12,41 +12,43 @@ - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - @@ -56,11 +58,11 @@ - - + + - - + + diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 76e14c8e6ce..8e4ca768b05 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -923,23 +923,23 @@ private MenuBar createMenu() { ); options.getItems().addAll( - factory.createMenuItem(StandardActions.SHOW_PREFS, new ShowPreferencesAction(this, Globals.TASK_EXECUTOR)), + factory.createMenuItem(StandardActions.SHOW_PREFS, new ShowPreferencesAction(this, Globals.TASK_EXECUTOR)), - new SeparatorMenuItem(), + new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()), - factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction()), - factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction()), - factory.createMenuItem(StandardActions.MANAGE_EXTERNAL_FILETYPES, new EditExternalFileTypesAction()), - factory.createMenuItem(StandardActions.MANAGE_JOURNALS, new ManageJournalsAction()), - factory.createMenuItem(StandardActions.CUSTOMIZE_KEYBINDING, new CustomizeKeyBindingAction()), - factory.createMenuItem(StandardActions.MANAGE_PROTECTED_TERMS, new ManageProtectedTermsAction(this, Globals.protectedTermsLoader)), + factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()), + factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction()), + factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction()), + factory.createMenuItem(StandardActions.MANAGE_EXTERNAL_FILETYPES, new EditExternalFileTypesAction()), + factory.createMenuItem(StandardActions.MANAGE_JOURNALS, new ManageJournalsAction()), + factory.createMenuItem(StandardActions.CUSTOMIZE_KEYBINDING, new CustomizeKeyBindingAction()), + factory.createMenuItem(StandardActions.MANAGE_PROTECTED_TERMS, new ManageProtectedTermsAction(this, Globals.protectedTermsLoader)), - new SeparatorMenuItem(), + new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.MANAGE_CONTENT_SELECTORS, new OldDatabaseCommandWrapper(Actions.MANAGE_SELECTORS, this, Globals.stateManager)), - factory.createMenuItem(StandardActions.CUSTOMIZE_ENTRY_TYPES, new CustomizeEntryAction(this)), - factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this))); + factory.createMenuItem(StandardActions.MANAGE_CONTENT_SELECTORS, new OldDatabaseCommandWrapper(Actions.MANAGE_SELECTORS, this, Globals.stateManager)), + factory.createMenuItem(StandardActions.CUSTOMIZE_ENTRY_TYPES, new CustomizeEntryAction(this)), + factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this))); help.getItems().addAll( factory.createMenuItem(StandardActions.HELP, HelpAction.getMainHelpPageCommand()), diff --git a/src/main/java/org/jabref/gui/PreviewPanel.java b/src/main/java/org/jabref/gui/PreviewPanel.java index ff8d6db01bd..796fafdd016 100644 --- a/src/main/java/org/jabref/gui/PreviewPanel.java +++ b/src/main/java/org/jabref/gui/PreviewPanel.java @@ -24,7 +24,7 @@ import javafx.scene.web.WebView; import org.jabref.Globals; -import org.jabref.gui.externalfiles.NewDroppedFileHandler; +import org.jabref.gui.externalfiles.ExternalFilesEntryLinker; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.keyboard.KeyBinding; @@ -61,9 +61,9 @@ public class PreviewPanel extends ScrollPane implements SearchQueryHighlightList private final DialogService dialogService; private final KeyBindingRepository keyBindingRepository; + private final String defaultPreviewStyle = "Preview"; private String previewStyle; private CitationStyle citationStyle; - private final String defaultPreviewStyle = "Preview"; private Optional basePanel = Optional.empty(); private boolean fixedLayout; @@ -80,7 +80,7 @@ public class PreviewPanel extends ScrollPane implements SearchQueryHighlightList private final WebView previewView; private Optional> citationStyleFuture = Optional.empty(); - private final NewDroppedFileHandler fileHandler; + private final ExternalFilesEntryLinker fileLinker; /** * @param panel (may be null) Only set this if the preview is associated to the main window. @@ -93,11 +93,7 @@ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, KeyBind this.clipBoardManager = Globals.clipboardManager; this.keyBindingRepository = keyBindingRepository; - fileHandler = new NewDroppedFileHandler(dialogService, databaseContext, externalFileTypes, - Globals.prefs.getFilePreferences(), - Globals.prefs.getImportFormatPreferences(), - Globals.prefs.getUpdateFieldPreferences(), - Globals.getFileUpdateMonitor()); + fileLinker = new ExternalFilesEntryLinker(externalFileTypes, Globals.prefs.getFilePreferences(), databaseContext); // Set up scroll pane for preview pane setFitToHeight(true); @@ -135,19 +131,18 @@ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, KeyBind List files = event.getDragboard().getFiles().stream().map(File::toPath).collect(Collectors.toList()); if (event.getTransferMode() == TransferMode.MOVE) { - LOGGER.debug("Mode MOVE"); //shift on win or no modifier - fileHandler.addToEntryRenameAndMoveToFileDir(entry, files); + fileLinker.moveFilesToFileDirAndAddToEntry(entry, files); } if (event.getTransferMode() == TransferMode.LINK) { LOGGER.debug("Node LINK"); //alt on win - fileHandler.addToEntry(entry, files); - + fileLinker.addFilesToEntry(entry, files); } if (event.getTransferMode() == TransferMode.COPY) { LOGGER.debug("Mode Copy"); //ctrl on win, no modifier on Xubuntu - fileHandler.copyFilesToFileDirAndAddToEntry(entry, files); + fileLinker.copyFilesToFileDirAndAddToEntry(entry, files); } + success = true; } event.setDropCompleted(success); diff --git a/src/main/java/org/jabref/gui/SidePaneManager.java b/src/main/java/org/jabref/gui/SidePaneManager.java index eef7f01098b..173a11a07c3 100644 --- a/src/main/java/org/jabref/gui/SidePaneManager.java +++ b/src/main/java/org/jabref/gui/SidePaneManager.java @@ -31,10 +31,10 @@ public SidePaneManager(JabRefPreferences preferences, JabRefFrame frame) { OpenOfficePreferences openOfficePreferences = preferences.getOpenOfficePreferences(); Stream.of( - new FileUpdatePanel(this), - new GroupSidePane(this, preferences, frame.getDialogService()), - new WebSearchPane(this, preferences, frame), - new OpenOfficeSidePanel(this, preferences, frame)) + new FileUpdatePanel(this), + new GroupSidePane(this, preferences, frame.getDialogService()), + new WebSearchPane(this, preferences, frame), + new OpenOfficeSidePanel(this, preferences, frame)) .forEach(pane -> components.put(pane.getType(), pane)); if (preferences.getBoolean(JabRefPreferences.GROUP_SIDEPANE_VISIBLE)) { diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java b/src/main/java/org/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java index 68006125528..f6c6aa5544c 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java +++ b/src/main/java/org/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java @@ -48,7 +48,7 @@ public ResolveDuplicateLabelDialog(BasePanel panel, String key, List e diag = new JDialog((JFrame) null, Localization.lang("Duplicate BibTeX key"), true); FormBuilder b = FormBuilder.create().layout(new FormLayout( - "left:pref, 4dlu, fill:pref", "p")); + "left:pref, 4dlu, fill:pref", "p")); b.add(new JLabel(Localization.lang("Duplicate BibTeX key") + ": " + key)).xyw(1, 1, 3); b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java index ee562c53401..0938f717905 100644 --- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java +++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java @@ -112,7 +112,6 @@ protected List call() throws InterruptedException, writeLogMessage(newFile, bw, localizedErrorMessage); addResultToList(newFile, success, localizedErrorMessage); } - } } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 4289c29d1b2..450da9e98d9 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -31,7 +31,7 @@ import org.jabref.gui.actions.GenerateBibtexKeySingleAction; import org.jabref.gui.actions.StandardActions; import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab; -import org.jabref.gui.externalfiles.NewDroppedFileHandler; +import org.jabref.gui.externalfiles.ExternalFilesEntryLinker; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.help.HelpAction; import org.jabref.gui.keyboard.KeyBinding; @@ -91,7 +91,7 @@ public class EntryEditor extends BorderPane { private final EntryEditorPreferences preferences; private final DialogService dialogService; - private final NewDroppedFileHandler fileHandler; + private final ExternalFilesEntryLinker fileLinker; private final TaskExecutor taskExecutor; public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpdateMonitor fileMonitor, DialogService dialogService, ExternalFileTypes externalFileTypes, TaskExecutor taskExecutor) { @@ -103,11 +103,7 @@ public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpda this.dialogService = dialogService; this.taskExecutor = taskExecutor; - fileHandler = new NewDroppedFileHandler(dialogService, databaseContext, externalFileTypes, - Globals.prefs.getFilePreferences(), - Globals.prefs.getImportFormatPreferences(), - Globals.prefs.getUpdateFieldPreferences(), - Globals.getFileUpdateMonitor()); + fileLinker = new ExternalFilesEntryLinker(externalFileTypes, Globals.prefs.getFilePreferences(), databaseContext); ViewLoader.view(this) .root(this) @@ -151,17 +147,17 @@ public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpda if (event.getTransferMode() == TransferMode.LINK) //alt on win { LOGGER.debug("Mode LINK"); - fileHandler.addToEntry(entry, files); + fileLinker.addFilesToEntry(entry, files); } else if (event.getTransferMode() == TransferMode.COPY) //ctrl on win, no modifier on Xubuntu { LOGGER.debug("Mode COPY"); - fileHandler.copyFilesToFileDirAndAddToEntry(entry, files); + fileLinker.copyFilesToFileDirAndAddToEntry(entry, files); } else { LOGGER.debug("Mode MOVE"); //shift on win or no modifier - fileHandler.addToEntryRenameAndMoveToFileDir(entry, files); + fileLinker.moveFilesToFileDirAndAddToEntry(entry, files); } } @@ -170,17 +166,17 @@ else if (event.getTransferMode() == TransferMode.COPY) //ctrl on win, no modifie if (event.getTransferMode() == TransferMode.COPY) //ctrl on win, no modifier on Xubuntu { LOGGER.debug("Mode MOVE"); - fileHandler.addToEntryRenameAndMoveToFileDir(entry, files); + fileLinker.moveFilesToFileDirAndAddToEntry(entry, files); } else if (event.getTransferMode() == TransferMode.LINK) //alt on win { LOGGER.debug("Mode LINK"); - fileHandler.addToEntry(entry, files); + fileLinker.addFilesToEntry(entry, files); } else { LOGGER.debug("Mode COPY"); //shift on win or no modifier - fileHandler.copyFilesToFileDirAndAddToEntry(entry, files); + fileLinker.copyFilesToFileDirAndAddToEntry(entry, files); } } @@ -189,17 +185,17 @@ else if (event.getTransferMode() == TransferMode.LINK) //alt on win if (event.getTransferMode() == TransferMode.COPY) //ctrl on win, no modifier on Xubuntu { LOGGER.debug("Mode COPY"); - fileHandler.copyFilesToFileDirAndAddToEntry(entry, files); + fileLinker.copyFilesToFileDirAndAddToEntry(entry, files); } else if (event.getTransferMode() == TransferMode.LINK) //alt on win { LOGGER.debug("Mode MOVE"); - fileHandler.addToEntryRenameAndMoveToFileDir(entry, files); + fileLinker.moveFilesToFileDirAndAddToEntry(entry, files); } else { LOGGER.debug("Mode LINK"); //shift on win or no modifier - fileHandler.addToEntry(entry, files); + fileLinker.addFilesToEntry(entry, files); } } } diff --git a/src/main/java/org/jabref/gui/entryeditor/SourceTab.java b/src/main/java/org/jabref/gui/entryeditor/SourceTab.java index b96fed0bea4..397e3abd921 100644 --- a/src/main/java/org/jabref/gui/entryeditor/SourceTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/SourceTab.java @@ -120,7 +120,7 @@ protected void bindToEntry(BibEntry entry) { } catch (IOException ex) { codeArea.setEditable(false); codeArea.appendText(ex.getMessage() + "\n\n" + - Localization.lang("Correct the entry, and reopen editor to display/edit source.")); + Localization.lang("Correct the entry, and reopen editor to display/edit source.")); LOGGER.debug("Incorrect entry", ex); } }); diff --git a/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialog.fxml b/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialog.fxml index 1c63d7e8008..64a4beed541 100644 --- a/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialog.fxml +++ b/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialog.fxml @@ -10,43 +10,45 @@ - - + - - - - - - - - - - - - - - - - - -