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

Fixed missing trigger for linked file operations #7548

Merged
merged 3 commits into from
Mar 18, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the password for a shared SQL database was only remembered if it was the same as the username [#6869](https://github.com/JabRef/jabref/issues/6869)
- We fixed an issue where some custom exports did not use the new authors formatter and therefore did not export authors correctly [#7356](https://github.com/JabRef/jabref/issues/7356)
- We fixed an issue where alt+keyboard shortcuts do not work [#6994](https://github.com/JabRef/jabref/issues/6994)
- We fixed an issue about the file link editor did not allow to change the file name according to the default pattern after changing an entry. [#7525](https://github.com/JabRef/jabref/issues/7525)
- We fixed an issue where the file path is invisible in dark theme. [#7382](https://github.com/JabRef/jabref/issues/7382)
- We fixed an issue where the secondary sorting is not working for some special fields. [#7015](https://github.com/JabRef/jabref/issues/7015)
- We fixed an issue where changing the font size makes the font size field too small. [#7085](https://github.com/JabRef/jabref/issues/7085)
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Optional;

import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import javafx.css.PseudoClass;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -48,6 +49,7 @@

import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
import com.tobiasdiez.easybind.optional.ObservableOptionalValue;

public class LinkedFilesEditor extends HBox implements FieldEditorFX {

Expand All @@ -59,6 +61,8 @@ public class LinkedFilesEditor extends HBox implements FieldEditorFX {
private final UiThreadObservableList<LinkedFileViewModel> decoratedModelList;
private final PreferencesService preferencesService;

private ObservableOptionalValue<BibEntry> bibEntry = EasyBind.wrapNullable(new SimpleObjectProperty<>());

public LinkedFilesEditor(Field field,
DialogService dialogService,
BibDatabaseContext databaseContext,
Expand Down Expand Up @@ -207,6 +211,7 @@ public LinkedFilesEditorViewModel getViewModel() {

@Override
public void bindToEntry(BibEntry entry) {
bibEntry = EasyBind.wrapNullable(new SimpleObjectProperty<>(entry));
viewModel.bindToEntry(entry);
}

Expand Down Expand Up @@ -281,19 +286,19 @@ public ContextAction(StandardActions command, LinkedFileViewModel linkedFile, Pr
() -> !linkedFile.getFile().isOnlineLink()
&& linkedFile.getFile().findIn(databaseContext, preferencesService.getFilePreferences()).isPresent()
&& !linkedFile.isGeneratedNameSameAsOriginal(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
case MOVE_FILE_TO_FOLDER -> Bindings.createBooleanBinding(
() -> !linkedFile.getFile().isOnlineLink()
&& linkedFile.getFile().findIn(databaseContext, preferencesService.getFilePreferences()).isPresent()
&& !linkedFile.isGeneratedPathSameAsOriginal(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
case DOWNLOAD_FILE -> Bindings.createBooleanBinding(
() -> linkedFile.getFile().isOnlineLink(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
case OPEN_FILE, OPEN_FOLDER, RENAME_FILE_TO_NAME, DELETE_FILE -> Bindings.createBooleanBinding(
() -> !linkedFile.getFile().isOnlineLink()
&& linkedFile.getFile().findIn(databaseContext, preferencesService.getFilePreferences()).isPresent(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
default -> BindingsHelper.constantOf(true);
});
}
Expand Down