From f20583dc4b08b73ca291735ebc4ae7e799b95390 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 18 Feb 2023 16:48:22 +0100 Subject: [PATCH 1/4] Refine error message and remove obsolete string --- .../linkedfiles/LinkedFilesTabViewModel.java | 31 ++++++++++++------- src/main/resources/l10n/JabRef_en.properties | 5 +-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java index ea38ed9f858..0954c8aa951 100644 --- a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java @@ -53,21 +53,28 @@ public LinkedFilesTabViewModel(DialogService dialogService, PreferencesService p mainFileDirValidator = new FunctionBasedValidator<>( mainFileDirectoryProperty, - input -> { + mainDirectoryPath -> { + ValidationMessage error = ValidationMessage.error(String.format( + "%s%n%s%n%n%s%n%n%s > %s > %s", + Localization.lang("Main directory not found"), + mainDirectoryPath, + Localization.lang("Please select a valid main directory under"), + Localization.lang("Linked files"), + Localization.lang("File directory"), + Localization.lang("Main file directory") + )); + try { - Path path = Path.of(mainFileDirectoryProperty.getValue()); - return (Files.exists(path) && Files.isDirectory(path)); + Path path = Path.of(mainDirectoryPath); + if (!(Files.exists(path) && Files.isDirectory(path))) { + return error; + } } catch (InvalidPathException ex) { - return false; + return error; } - }, - ValidationMessage.error(String.format("%s > %s > %s %n %n %s", - Localization.lang("File"), - Localization.lang("External file links"), - Localization.lang("Main file directory"), - Localization.lang("Directory not found") - ) - ) + // main directory is valid + return null; + } ); } diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 5f117b17085..29d1e8ebfd8 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -337,8 +337,6 @@ Extension=Extension External\ Changes\ Resolver=External Changes Resolver -External\ file\ links=External file links - External\ programs=External programs Failed\ to\ import\ by\ ID=Failed to import by ID @@ -2529,3 +2527,6 @@ Use\ the\ field\ FJournal\ to\ store\ the\ full\ journal\ name\ for\ (un)abbrevi Library\ to\ import\ into=Library to import into Multiline=Multiline + +Main\ directory\ not\ found=Main directory not found +Please\ select\ a\ valid\ main\ directory\ under=Please select a valid main directory under From 16dd1d8a9900e85ee8011396423f218ceb40c6b3 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 18 Feb 2023 16:54:46 +0100 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c4b1a89385..995ab78011f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Changed - +- We refined the 'main directory not found' error message. [#9625](https://github.com/JabRef/jabref/pull/9625) From c7dadfab50d928482bdfc9a5ac4252ac6eb53118 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 18 Feb 2023 17:01:02 +0100 Subject: [PATCH 3/4] Checkstyle --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 995ab78011f..5f92451b553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Changed -- We refined the 'main directory not found' error message. [#9625](https://github.com/JabRef/jabref/pull/9625) +- We refined the 'main directory not found' error message. [#9625](https://github.com/JabRef/jabref/pull/9625) From e32800952f208328d51ed56db5dd5f1cf7a8e6dd Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Wed, 22 Feb 2023 14:01:46 +0100 Subject: [PATCH 4/4] Show error only if user selected to store files in main directory --- .../gui/preferences/linkedfiles/LinkedFilesTabViewModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java index 0954c8aa951..a566cbcdf67 100644 --- a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java @@ -127,7 +127,7 @@ ValidationStatus mainFileDirValidationStatus() { @Override public boolean validateSettings() { ValidationStatus validationStatus = mainFileDirValidationStatus(); - if (!validationStatus.isValid()) { + if (!validationStatus.isValid() && useMainFileDirectoryProperty().get()) { validationStatus.getHighestMessage().ifPresent(message -> dialogService.showErrorDialogAndWait(message.getMessage())); return false;