Skip to content

Commit

Permalink
fix for issue #7719, v3
Browse files Browse the repository at this point in the history
  • Loading branch information
devinluo27 committed May 20, 2021
1 parent 5f11f2d commit 57f1861
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the article title with colon fails to download the arXiv link (pdf file). [#7660](https://github.com/JabRef/issues/7660)
- We fixed an issue where the keybinding for delete entry did not work on the main table [7580](https://github.com/JabRef/jabref/pull/7580)
- We fixed an issue where the RFC fetcher is not compatible with the draft [7305](https://github.com/JabRef/jabref/issues/7305)
- We fixed an issue where the `Aux file` on `Edit group` doesn't support relative sub-directories path to import. [#7719](https://github.com/JabRef/jabref/issues/7719).

### Removed

Expand Down
16 changes: 12 additions & 4 deletions src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void setupValidation() {
if (StringUtil.isBlank(input)) {
return false;
} else {
Path texFilePath = preferencesService.getWorkingDir().resolve(input);
Path texFilePath = getAbsoluteTexGroupPath(input);
if (!Files.isRegularFile(texFilePath)) {
return false;
}
Expand Down Expand Up @@ -263,6 +263,16 @@ private void setupValidation() {
});
}

/**
* gets the absolute path relative to getLatexFileDirectory, if given a relative path
* @param input the user input path
* @return an absolute path
*/
private Path getAbsoluteTexGroupPath(String input) {
Optional<Path> latexFileDirectory = currentDatabase.getMetaData().getLatexFileDirectory(preferencesService.getUser());
return latexFileDirectory.map(path -> path.resolve(input)).orElse(Path.of(input));
}

public void validationHandler(Event event) {
ValidationStatus validationStatus = validator.getValidationStatus();
if (validationStatus.getHighestMessage().isPresent()) {
Expand Down Expand Up @@ -335,12 +345,10 @@ public AbstractGroup resultConverter(ButtonType button) {
FieldFactory.parseField(autoGroupPersonsFieldProperty.getValue().trim()));
}
} else if (typeTexProperty.getValue()) {
// issue 7719: add workingDir to filepath if it is relative
Path inputPath = preferencesService.getWorkingDir().resolve(Path.of(texGroupFilePathProperty.getValue().trim()));
resultingGroup = TexGroup.create(
groupName,
groupHierarchySelectedProperty.getValue(),
inputPath,
Path.of(texGroupFilePathProperty.getValue().trim()),
new DefaultAuxParser(new BibDatabase()),
Globals.getFileUpdateMonitor(),
currentDatabase.getMetaData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ private void notifyAboutChange(Path path) {
public void addListenerForFile(Path file, FileUpdateListener listener) throws IOException {
if (isActive()) {
// We can't watch files directly, so monitor their parent directory for updates
// toAbsolutePath() will add the path to Jabref as home directory to file, if file is not a absolute path
Path directory = file.toAbsolutePath().getParent();
directory.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY);
listeners.put(file, listener);
Expand Down

0 comments on commit 57f1861

Please sign in to comment.