From 380b05c4d31312f88f1eb589b281d14b430f7510 Mon Sep 17 00:00:00 2001 From: David Wade Date: Sun, 23 Oct 2022 17:35:08 +1100 Subject: [PATCH 1/5] Linked default directory to current library general path --- .../gui/externalfiles/UnlinkedFilesDialogView.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index 7202751ef5e..deaa9d68e19 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -42,6 +42,8 @@ import org.jabref.gui.util.ViewModelTreeCellFactory; import org.jabref.logic.importer.ImportFormatReader; import org.jabref.logic.l10n.Localization; +import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.metadata.MetaData; import org.jabref.model.util.FileUpdateMonitor; import org.jabref.preferences.PreferencesService; @@ -86,6 +88,9 @@ public class UnlinkedFilesDialogView extends BaseDialog { private final ControlsFxVisualizer validationVisualizer; private UnlinkedFilesDialogViewModel viewModel; + private BibDatabaseContext bibDatabase; + private MetaData metaData; + public UnlinkedFilesDialogView() { this.validationVisualizer = new ControlsFxVisualizer(); @@ -109,6 +114,8 @@ public UnlinkedFilesDialogView() { private void initialize() { viewModel = new UnlinkedFilesDialogViewModel(dialogService, undoManager, fileUpdateMonitor, preferencesService, stateManager, taskExecutor, importFormatReader); + this.bibDatabase = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null")); + progressDisplay.progressProperty().bind(viewModel.progressValueProperty()); progressText.textProperty().bind(viewModel.progressTextProperty()); progressPane.managedProperty().bind(viewModel.taskActiveProperty()); @@ -160,6 +167,9 @@ private void initDirectorySelection() { fileSortCombo.setItems(viewModel.getSorters()); fileSortCombo.valueProperty().bindBidirectional(viewModel.selectedSortProperty()); fileSortCombo.getSelectionModel().selectFirst(); + + + directoryPathField.setText(bibDatabase.getMetaData().getDefaultFileDirectory().isPresent() ? bibDatabase.getMetaData().getDefaultFileDirectory().get() : ""); } private void initUnlinkedFilesList() { From f00b8430ab5a67dbfba8027bc350a6cf5e886b7d Mon Sep 17 00:00:00 2001 From: David Wade Date: Sun, 23 Oct 2022 21:44:11 +1100 Subject: [PATCH 2/5] Documented koppor#546 additions --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ed74a68e2c..a6fe286f545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - An SLR can now be started from the SLR itself. [#9131](https://github.com/JabRef/jabref/pull/9131), [koppor#601](https://github.com/koppor/jabref/issues/601) - Implement a new ISBN Fetcher ([doi-to-bibtex-converter.herokuapp.com](http://doi-to-bibtex-converter.herokuapp.com) as source). [#9145](https://github.com/JabRef/jabref/pull/9145) - We added support for the Ukrainian and Arabic languages. [#9236](https://github.com/JabRef/jabref/pull/9236), [#9243](https://github.com/JabRef/jabref/pull/9243) +- Changing a library's general file directory will be reflected in the default directory for unlinked file lookup, [koppor#546](https://github.com/koppor/jabref/issues/546) ### Changed From 5785c8b1570b46903e509875a74d6d185d864bad Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 3 Nov 2022 18:28:04 +0100 Subject: [PATCH 3/5] use getFirstExistingFileDirectory --- CHANGELOG.md | 2 +- .../gui/externalfiles/UnlinkedFilesDialogView.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9c659eb0a5..19593e2f65d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - An SLR can now be started from the SLR itself. [#9131](https://github.com/JabRef/jabref/pull/9131), [koppor#601](https://github.com/koppor/jabref/issues/601) - Implement a new ISBN Fetcher ([doi-to-bibtex-converter.herokuapp.com](http://doi-to-bibtex-converter.herokuapp.com) as source). [#9145](https://github.com/JabRef/jabref/pull/9145) - We added support for the Ukrainian and Arabic languages. [#9236](https://github.com/JabRef/jabref/pull/9236), [#9243](https://github.com/JabRef/jabref/pull/9243) -- Changing a library's general file directory will be reflected in the default directory for unlinked file lookup, [koppor#546](https://github.com/koppor/jabref/issues/546) +- Changing the default file directory will be reflected in the default directory for unlinked file lookup. [koppor#546](https://github.com/koppor/jabref/issues/546) ### Changed diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index deaa9d68e19..f38bdf48c2d 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -1,5 +1,7 @@ package org.jabref.gui.externalfiles; +import java.nio.file.Path; + import javax.swing.undo.UndoManager; import javafx.application.Platform; @@ -88,7 +90,7 @@ public class UnlinkedFilesDialogView extends BaseDialog { private final ControlsFxVisualizer validationVisualizer; private UnlinkedFilesDialogViewModel viewModel; - private BibDatabaseContext bibDatabase; + private BibDatabaseContext bibDatabaseContext; private MetaData metaData; public UnlinkedFilesDialogView() { @@ -114,7 +116,7 @@ public UnlinkedFilesDialogView() { private void initialize() { viewModel = new UnlinkedFilesDialogViewModel(dialogService, undoManager, fileUpdateMonitor, preferencesService, stateManager, taskExecutor, importFormatReader); - this.bibDatabase = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null")); + this.bibDatabaseContext = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null")); progressDisplay.progressProperty().bind(viewModel.progressValueProperty()); progressText.textProperty().bind(viewModel.progressTextProperty()); @@ -168,8 +170,7 @@ private void initDirectorySelection() { fileSortCombo.valueProperty().bindBidirectional(viewModel.selectedSortProperty()); fileSortCombo.getSelectionModel().selectFirst(); - - directoryPathField.setText(bibDatabase.getMetaData().getDefaultFileDirectory().isPresent() ? bibDatabase.getMetaData().getDefaultFileDirectory().get() : ""); + directoryPathField.setText(bibDatabaseContext.getFirstExistingFileDir(preferencesService.getFilePreferences()).map(Path::toString).orElse("")); } private void initUnlinkedFilesList() { From c8604d8afccdfe023c3d9974ca5e4ffa47e0eadd Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 5 Nov 2022 17:48:22 +0100 Subject: [PATCH 4/5] remove unused field Change message --- .../org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index f38bdf48c2d..13ddbe4bd34 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -45,7 +45,6 @@ import org.jabref.logic.importer.ImportFormatReader; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.metadata.MetaData; import org.jabref.model.util.FileUpdateMonitor; import org.jabref.preferences.PreferencesService; @@ -91,7 +90,6 @@ public class UnlinkedFilesDialogView extends BaseDialog { private UnlinkedFilesDialogViewModel viewModel; private BibDatabaseContext bibDatabaseContext; - private MetaData metaData; public UnlinkedFilesDialogView() { this.validationVisualizer = new ControlsFxVisualizer(); @@ -116,7 +114,7 @@ public UnlinkedFilesDialogView() { private void initialize() { viewModel = new UnlinkedFilesDialogViewModel(dialogService, undoManager, fileUpdateMonitor, preferencesService, stateManager, taskExecutor, importFormatReader); - this.bibDatabaseContext = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null")); + this.bibDatabaseContext = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("No active library")); progressDisplay.progressProperty().bind(viewModel.progressValueProperty()); progressText.textProperty().bind(viewModel.progressTextProperty()); From 1009aed62b5f0fa9a8157ad35a2a5d19b1d3d031 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 6 Nov 2022 15:23:43 +0100 Subject: [PATCH 5/5] Fix changelog text --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19593e2f65d..b64a8caac47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - An SLR can now be started from the SLR itself. [#9131](https://github.com/JabRef/jabref/pull/9131), [koppor#601](https://github.com/koppor/jabref/issues/601) - Implement a new ISBN Fetcher ([doi-to-bibtex-converter.herokuapp.com](http://doi-to-bibtex-converter.herokuapp.com) as source). [#9145](https://github.com/JabRef/jabref/pull/9145) - We added support for the Ukrainian and Arabic languages. [#9236](https://github.com/JabRef/jabref/pull/9236), [#9243](https://github.com/JabRef/jabref/pull/9243) -- Changing the default file directory will be reflected in the default directory for unlinked file lookup. [koppor#546](https://github.com/koppor/jabref/issues/546) +- The default file directory of a library is used as default directory for [unlinked file lookup](https://docs.jabref.org/collect/findunlinkedfiles#link-the-pdfs-to-your-bib-library). [koppor#546](https://github.com/koppor/jabref/issues/546) ### Changed