Skip to content

Commit

Permalink
Merge pull request #9625 from HoussemNasri/refine-not-found-main-dire…
Browse files Browse the repository at this point in the history
…ctory-error

Refine main directory not found error message
  • Loading branch information
Siedlerchr authored Feb 22, 2023
2 parents 563f52f + e328009 commit 76b221d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
);
}

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 76b221d

Please sign in to comment.