Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine main directory not found error message #9625

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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