diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c4b1a89385..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) 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..a566cbcdf67 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; + } ); } @@ -120,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; 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