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

Bind "Find unlinked files" default directory to the current library #9290

Merged
merged 6 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.externalfiles;

import java.nio.file.Path;

import javax.swing.undo.UndoManager;

import javafx.application.Platform;
Expand Down Expand Up @@ -42,6 +44,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;

Expand Down Expand Up @@ -86,6 +90,9 @@ public class UnlinkedFilesDialogView extends BaseDialog<Void> {
private final ControlsFxVisualizer validationVisualizer;
private UnlinkedFilesDialogViewModel viewModel;

private BibDatabaseContext bibDatabaseContext;
private MetaData metaData;

public UnlinkedFilesDialogView() {
this.validationVisualizer = new ControlsFxVisualizer();

Expand All @@ -109,6 +116,8 @@ public UnlinkedFilesDialogView() {
private void initialize() {
viewModel = new UnlinkedFilesDialogViewModel(dialogService, undoManager, fileUpdateMonitor, preferencesService, stateManager, taskExecutor, importFormatReader);

this.bibDatabaseContext = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you improve the error message please? Remember we are dealing with users, not coders. ;-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also check that the calling UI command requires an opened database.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already checked in the action


progressDisplay.progressProperty().bind(viewModel.progressValueProperty());
progressText.textProperty().bind(viewModel.progressTextProperty());
progressPane.managedProperty().bind(viewModel.taskActiveProperty());
Expand Down Expand Up @@ -160,6 +169,8 @@ private void initDirectorySelection() {
fileSortCombo.setItems(viewModel.getSorters());
fileSortCombo.valueProperty().bindBidirectional(viewModel.selectedSortProperty());
fileSortCombo.getSelectionModel().selectFirst();

directoryPathField.setText(bibDatabaseContext.getFirstExistingFileDir(preferencesService.getFilePreferences()).map(Path::toString).orElse(""));
}

private void initUnlinkedFilesList() {
Expand Down